Invoice to Serialized Equipment
When an Invoice is submitted in Zoho Books, an Equipment record is created in Zoho CRM that tracks which specific units a customer owns.
// Get Invoice Information
invoiceNumber = invoice.get("invoice_number");
invoiceId = invoice.get("invoice_id");
customerName = invoice.get("customer_name");
// Get CRM Account ID
customerNameEncoded = zoho.encryption.urlEncode(customerName);
searchAccounts = invokeurl
[
url :"https://www.zohoapis.com/crm/v2/Accounts/search?criteria=(Account_Name:equals:" + customerNameEncoded + ")"
type :GET
connection:"crm_modules_full"
];
crmAccount = searchAccounts.get("data").get(0);
crmAccountId = crmAccount.get("id");
crmAccountName = crmAccount.get("Account_Name");
// Process line items, serial numbers, and create Equipment records in Zoho CRM
lineItems = invoice.get("line_items");
// Iterate through line items to see if there are serial numbers attached
for each lineItem in lineItems
{
sku = lineItem.get("sku");
itemName = lineItem.get("name");
serialNumbers = lineItem.get("serial_numbers");
// Iterate through specific serial numbers and check if Equipment record has been created
for each serialNumber in serialNumbers
{
// Search for existing Equipment record with matching serial number
searchEquipment = zoho.crm.searchRecords("Equipment","(Serial_Number:equals:" + serialNumber + ")");
// No existing equipment record
if(searchEquipment.isEmpty())
{
equipmentMap = {"Name":itemName + " | " + crmAccountName,"Associated_Account":crmAccountId,"Product_Name":itemName,"Serial_Number":serialNumber,"SKU":sku,"Invoice_Number":invoiceNumber,"Invoice_URL":"https://books.zoho.com/app#/invoices/" + invoiceId,"Status":"Active"};
createEquipment = zoho.crm.createRecord("Equipment", equipmentMap);
}
// Equipment Record Already Exists
else
{
info "Equipment record with serial number " + serialNumber + " already found.";
}
}
}
Click here to copy these scripts. For more Zoho-wizardry, check out our GitHub page.
Want to learn even more?
Sign up for one of our Zoho courses!
0 Lessons
Should I Use Zoho Meeting, or Another Webinar/Web Conferencing Tool?
0% Complete
0/0 Steps
Want this functionality, but don't want to do it yourself?
Click here to speak to us!
Need help with your Zoho system?
Hire a full time Zoho System Admin from our poolof highly qualified program graduates!

Related Resources
This set up allows you to insert subform rows and add to picklist dynamically with...
Deluge script for sorting lists containing maps by the specific key (by date-time/alphabetical...
When scripting, ask yourself this question - will this value ever be null? If it's...
This script allows you to create a HTML table in Deluge with dynamic rows, then merge...
When a Zoho CRM record is created/updated/deleted via Deluge, the system does not...
Click Here to Apply
Description
Location
Bastrop/Smithville area
Role
Entry...
Click Here to Apply
Description
Location
New Braunfels area
Role
The Partner...
This tutorial will illustrate how to create a custom function (using Deluge scripting)...
This tutorial demonstrates the integration between Shopify and Zoho Inventory. Use...
This tutorial provides a Creator script that loads related records from Zoho CRM...