Zoho Inventory

Zoho Creator & Zoho CRM Integration

  • Custom workflow to create/update data into other app.
  • 2 workflow for each module.
  • 1st is set on condition when record is created/edited
  • 2nd is set on condition when record is deleted.
  • Connection is created in both apps.
Workflows::
  1. when Sales order is created/updated into the Zoho Inventory.
  • This workflow is sending sales order data into zoho Creator.
  • If Customer email is already exist
salesorderdate = salesorder.get("date").toDate();
SOID = salesorder.get("salesorder_id");
organizationID = organization.get("organization_id");
custID = salesorder.get("customer_id");
// Find Customer from creator
findcustomer = zoho.creator.getRecords("ketaichina","customer-balances","All_Customers","Customer_ID==" + custID,1,200,"zohocreatorinte");
fff = findcustomer.get("code");
//Fetch Customer details from Inventory;
fetchcustomer2 = zoho.inventory.getRecordsByID("contacts",organizationID,custID,"zohoinventory");
mymap = Map();
info fff;
if(fff == 3100)
{
	value1 = "";
	custid = fetchcustomer2.get("contact").get("contact_id");
	custname = fetchcustomer2.get("contact").get("contact_name");
	compname = fetchcustomer2.get("contact").get("company_name");
	desiname = fetchcustomer2.get("contact").get("designation");
	depaname = fetchcustomer2.get("contact").get("department");
	custemail = fetchcustomer2.get("contact").get("email");
	custphone = fetchcustomer2.get("contact").get("phone");
	custmobile = fetchcustomer2.get("contact").get("mobile");
	custtype = fetchcustomer2.get("contact").get("customer_sub_type");
	paymentterms = fetchcustomer2.get("contact").get("payment_terms_label");
	currencysymbol = fetchcustomer2.get("contact").get("currency_symbol");
	customer = Map();
	customer.put("Customer_ID",custid);
	customer.put("Customer_Name",custname);
	customer.put("Company_Name",compname);
	customer.put("Designation",desiname);
	customer.put("Department",depaname);
	customer.put("Email",custemail);
	customer.put("Phone_Number",custphone);
	customer.put("Mobile",custmobile);
	customer.put("Customer_Type",custtype);
	customer.put("Payment_Terms",paymentterms);
	customer.put("Currency_Symbol",currencysymbol);
	otherParams = Map();
	creatorcust = zoho.creator.createRecord("ketaichina","customer-balances","Customers",customer,otherParams,"zohocreatorinte");
	//info creatorcust;
	findcustomer3 = zoho.creator.getRecords("ketaichina","customer-balances","All_Customers","Customer_ID==" + custID,1,200,"zohocreatorinte");
	nnn = findcustomer3.get("data").getJSON("ID");
	mymap.put("Customer",nnn);
}
else
{
	mymap.put("Customer",findcustomer.get("data").getJSON("ID"));
	info findcustomer.get("data").getJSON("ID");
}
mymap.put("Customer_ID",salesorder.get("customer_id"));
mymap.put("Customer_Name",salesorder.get("customer_name"));
mymap.put("SO_ID",salesorder.get("salesorder_id"));
mymap.put("SO_Number",salesorder.get("salesorder_number"));
mymap.put("Date_field",salesorder.get("date"));
mymap.put("Expected_Shipment_Date",salesorder.get("date_formatted"));
mymap.put("Amount",salesorder.get("total"));
mymap.put("Total_Quantity",salesorder.get("quantity"));
lineitem = salesorder.get("line_items");
info salesorder.get("shipment_date");
for each  lines in lineitem
{
	info lines.get("line_item_id") + " : " + lines.get("name") + " : " + lines.get("item_total");
	line2 = Map();
	line2.put("Item_Type",lines.get("item_type"));
	line2.put("Item_Name",lines.get("name"));
	line2.put("SKU",lines.get("sku"));
	line2.put("Unit",lines.get("unit"));
	line2.put("Tax",lines.get("tax_percentage"));
	line2.put("Selling_Price",lines.get("rate"));
	line2.put("Total_Item",lines.get("item_total"));
	line2.put("Pcs_in_carton",lines.get("quantity"));
	linevalues = Collection();
	linevalues.insert(line2);
	mymap.put("Item_Details",linevalues);
}
findsalesorder = zoho.creator.getRecords("ketaichina","customer-balances","Sales_Order_Report","SO_ID==" + SOID,1,200,"zohocreatorinte");
FSO = findsalesorder.get("code");
info FSO;
otherParams2 = Map();
if(FSO == 3100)
{
	response = zoho.creator.createRecord("ketaichina","customer-balances","Sales_Order",mymap,otherParams2,"zohocreatorinte");
	info response;
}
else if(FSO == 3000)
{
	response2 = zoho.creator.updateRecords("ketaichina","customer-balances","Sales_Order_Report",SOID,mymap,otherParams2,"zohocreatorinte");
	info response2;
}

Leave a Comment