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 custom 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, custom functions are required to extend this functionality to other fields.
Through this custom 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 and Fields > Select the required module > Links and Buttons > + New Button.
- Provide a name for the button. Add a description(optional).
- Choose View Page from the drop-down list.
- Select Writing Function from the subsequent drop-down.
- Provide a name for the custom function. Add a description(optional).
- Copy the code given below.
- Click Edit Arguments.
- Enter the name as potId and select the value as Deal Id.
- Enter the name as value and select the value as Expected Revenue.
- Save the changes.
- Select the profiles who can see this button.
- Click Save.
The Code:
For amount:
mp=map();
mp.put("Amount",input.value);
update=zoho.crm.update("Deals",input.potId.toLong(), mp);
info mp;
info update;
return "Success";
For mobile:
mp = map();
mp.put("Mobile", input.phone);
update = zoho.crm.update("Leads",input.leadId.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 and Fields > Select the 'Leads' module > Links and Buttons > + New Button.
- Provide a name for the button. For example: "Update Contact details in Deals". Add a description(optional).
- Choose View Page from the drop-down list.
- Select Writing Function from the subsequent drop-down.
- Provide a name for the custom function. Add a description(optional).
- 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.
- Save the changes.
- Save the button.
The Code:
For mobile:
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 custom function is not limited to the above two use cases. To use the same custom function for updating other fields, replace the source and destination fields in the code accordingly.
- In Zoho CRM, the Deals module was formerly referred to as Potentials.
- 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!