Testing Our Function

Once you have the Invoice map created and you run your createInvoice command, you’re finished!

UPDATE: since recording this course, Zoho decided to require the connection name as a parameter in the zoho.books.createRecord integration task. So, instead of your code ending with your map as mine does here 20 seconds into the video, you must add the connection name.

i.e. createInvoice = zoho.books.createRecord(“invoices”, orgId, invoice, “zohobooks”);

Just to wrap up, this is what happens in the code:

  • The code takes the Amount, Deal ID, Deal Owner and Financial Advisor from the Deal record
  • It calculates the Commission Amount based on the Deal Amount using an IF statement
  • It uses a ‘For Each’ loop to create, using the same map, a commission record for each employee involved
  • Then, we take the Account Name (also from the Deal record) and search the Customers in Zoho Books for it
  • If we find a Customer (API name of Contacts, it’s weird) for it, we get that Customer’s ID
  • If not, we create a Customer record and get its ID
  • Then, we create an Invoice map, assigned to the right Customer (ID)
  • We add the line items and create the invoice

That’s a lot! Way to go. Of course, there is more you can do to make this function even more smooth and versatile. But, this is a big step toward becoming a Deluge guru.

Link to our GitHub repository with this code