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?
The custom function for today 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:
- Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
- Provide a name for the function. For example: "Auto Update Tasks from related lists".
- Select the moduleto be associated as Tasks. Add a description(optional).
- Copy the code given below.
- Click "Edit arguments".
- Enter the name as "quoteId" and select the value as "Quote Id".
- Enter the name as "contId" and select the value as "Contact Id".
- Click Save & Execute Script.
- Save the changes.
The code:
For v2 Editor - DRE:
contDetails = zoho.crm.getRecordById("Contacts", input.contId.toLong());
mp=map();
mp.put("First_Name",ifnull(contDetails.get("First_Name"),""));
mp.put("Last_Name",ifnull(contDetails.get("Last_Name"),""));
mp.put("Broker_First_Name",ifnull(contDetails.get("Broker_First_Name"),""));
mp.put("Broker_Last_Name",ifnull(contDetails.get("Broker_Last_Name"),""));
mp.put("Property_Street",ifnull(contDetails.get("Property_Street"),""));
mp.put("Property_City",ifnull(contDetails.get("Property_City"),""));
mp.put("Property_State",ifnull(contDetails.get("Property_State"),""));
mp.put("Property_Zip",ifnull(contDetails.get("Property_Zip"),""));
updateResp= zoho.crm.update("Quotes",input.quoteId.toLong(), mp);
info mp;
info updateResp;
Note:
- This function code works only when you have the latest version of Zoho CRM's APIs.
- 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.
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!