Update information between two modules via Lookup fields

Business scenario:

Quotes are binding agreements between a customer and a vendor, to deliver the requested products to the customer within a specified time-frame at a predefined price. Your customers can place orders within a stipulated period (validity date) that has been mentioned in the quote, otherwise you may cancel or extend the time-frame by sending a new quote. In general, a Quote contains the Quote Number, Date, Line Items(Products) inclusive of quantity and prices based on your Price Books, Terms & Conditions and Description.

And incidently, the quote can be sent to a specific Contact or an Account. Depending on the scenario, the information to be on the quote may differ. For instance, you may want to add the Contact Phone number, Email address, Description or any information in a custom field to the quote. The Quotes module indeed has a lookup field for Contact, Deal and Account. Meaning, the information from a Contact, Deal or an Account can be copied automatically to a Quote through the lookup. So where does this custom function fit in?

It's for the information fields which are not available in a Quote. Information which is not normally available to be stored in the CRM can be stored using a custom field. Similarly, the modules Quotes, Invoice and modules like that have to be updated to store that additional information too. Are you going to juggle between modules to copy each additional information when a lookup is already available?

This custom function latches on to the Lookup field and whenever a Contact is selected as a lookup, the custom fields specified in the custom function are also transferred automatically. Furthermore, this custom function is not limited to the Quotes module. You can use this function to any module that has a Lookup field.


Getting started with the function:

  1. Go to Setup > Automation > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: “Auto-populate deal amount”. Add a description(optional).
  3. Choose the module as Deals.
  4. Copy the code given below.
  5. Click Edit Arguments.
  6. Enter the name as quoteId and select the value as Quote Id.
  7. Enter the name as contId and select the value as Contact Id.
  8. Save the changes.

The Code:

contDetails = zoho.crm.getRecordById("Contacts", input.contId.toLong());
updateResp= zoho.crm.update("Quotes",input.quoteId.toLong(), mp);
info mp;
info updateResp;


Adding to the workflow

  1. Go to Setup > Automation > Workflow Rules.
  2. Click '+ Create Rule'.
  3. Select the Module for which this custom function has to be added and give it a name and a description(optional).
  4. Select "Create or Edit" under "On a record action", in the "When do you want to execute this rule?".
  5. Select the Condition as "All Records" and click Next.
  6. Choose "Function" from Instant Actions.
  7. Select the option "Function" (Created by users from your organization).
  8. Select the required custom function and click Publish.
  9. Provide a Description for the custom function and Publish it.
  10. Save the workflow.


  • You can use the code on any module. Change the name of the module from 'Quotes' to whichever module you prefer and update the code accordingly.
  • The Fields in the left section (right after mp.put) of the code are the destination fields and the ones in the right are the source fields. Update your code according to your requirement and your fields.
  • If there is a need to copy information from a custom field, you need to create that custom field for the destination module too.
  • The above code works only for API V2.0 and not the previous version.

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips