Auto-update multiple fields of a record with same details.
Business scenario:
Recently, we got an interesting request from one of our customers. She was looking to update multiple fields of a record with the same details. Though copy-paste was an obvious solution, she was convinced that automation would help cut down on errors resulting from manual work. Our team noted her requirements carefully and came up with tailor-made functions that delighted her.
Though the use-case appeared vague initially, at hindsight, we were convinced of its utility for customers at large. Here are two top-of-the-mind examples that we could think of:
- Copying the amount value from 'Expected Revenue' field to the 'Amount' field in a Deals module.
- Copying the information from the 'Phone' field to the 'Mobile' field in Leads module.
It's important to note that such options are available out-of-the-box for updating 'Billing Address' to 'Shipping Address' and vice versa. However, functions are required to extend this functionality to other fields.
Through this function, information from one field can be transferred to another field within a record, at the click of a button.
Getting started with the function:
Example 1: Update the 'Amount' field value with information from 'Expected Revenue' field in Deals module.
- Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
- Provide a name for the button. For example: "[The button's name]". Add a description(optional).
- Select the placement of the button as View page.
- Select the action to be performed as "Writing function".
- Copy the code given below.
- Click "Edit arguments".
- Enter the name as "dealId" and select the value as "Deal Id".
- Enter the name as "value" and select the value as "Potential Expected Revenue".
- Click Save & Execute Script.
- Save the changes.
- Select the profiles who can view this button.
- Click Save.
The code:
For v2 Editor - DRE:
mp=map();
mp.put("Amount",input.value);
update=zoho.crm.update("Deals",input.potId.toLong(), mp);
info mp;
info update;
return "Success"
Example 2: Update a "Mobile" field with information from "Phone" field in Leads module.
- Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
- Provide a name for the button. For example: "[The button's name]". Add a description(optional).
- Select the placement of the button as View page.
- Select the action to be performed as "Writing function".
- Copy the code given below.
- Click "Edit arguments".
- Enter the name as "leadId" and select the value as "Lead Id".
- Enter the name as "phone" and select the value as "Lead Phone".
- Click Save & Execute Script.
- Save the changes.
- Select the profiles who can view this button.
- Click Save.
The code:
For v2 Editor - DRE:
mp = map();
mp.put("Mobile", input.phone);
update = zoho.crm.update("Leads",input.leadId.toLong(), mp);
info mp;
info update;
return "Success";
Note:
- The utility of this function is not limited to the above two use cases. To use the same function for updating other fields, replace the source and destination fields in the code accordingly.
- This function works only when you create a deal using the linked button.
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!