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.

  1. Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
  2. Provide a name for the button. For example: "[The button's name]". Add a description(optional).
  3. Select the placement of the button as View page.
  4. Select the action to be performed as "Writing function".
  5. Copy the code given below.
  6. Click "Edit arguments".
  7. Enter the name as "dealId" and select the value as "Deal Id".
  8. Enter the name as "value" and select the value as "Potential Expected Revenue".
  9. Click Save & Execute Script.
  10. Save the changes.
  11. Select the profiles who can view this button.
  12. 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.

  1. Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
  2. Provide a name for the button. For example: "[The button's name]". Add a description(optional).
  3. Select the placement of the button as View page.
  4. Select the action to be performed as "Writing function".
  5. Copy the code given below.
  6. Click "Edit arguments".
  7. Enter the name as "leadId" and select the value as "Lead Id".
  8. Enter the name as "phone" and select the value as "Lead Phone".
  9. Click Save & Execute Script.
  10. Save the changes.
  11. Select the profiles who can view this button.
  12. 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!

Return to Tips