Lesson Progress
0% Complete

Take a look at the code snippet below or check out the entire function in our Github repository

*NOTE: One thing we would suggest changing from what we have in the video is searching for the Zoho Books customer via the Account Name instead of the email. Books is a little weird concerning how it deals with email data and it’s much more reliable to search for the Customer name using the “Account_Name” that is tied to the specific Deal. The Account Name syncs to the Customer Name field in the CRM-Books sync and you’ll always find a match, (presupposing your Deal is tied to an Account).

// Grab the Deal from which the Sign doc was created
 dealId = grabDocument.get("custom_data").get("record");
 dealRecord = zoho.crm.getRecordById("Deals",dealId);
	customerName = dealRecord.get("Account_Name").get("name")
 discount = dealRecord.get("Discount");
 amount = dealRecord.get("Amount");
 itemID = "2342210000008111017";
 monthly = amount / installments;
 info "Monthly Payment: " + monthly;
 // Grab the Books Contact and begin the Invoice map
 params = {"contact_name":customerName};
 booksSearch = zoho.books.getRecords("contacts",orgId,params,"zohobooks");
 info booksSearch;
 customer = booksSearch.get("contacts").get("0");
 customerID = customer.get("contact_id");
 info customerID;