Concatenate two fields into a single one.
Leads are acquired from a variety of sources. Trade fairs, web-forms, referrals, etc are some of the sources. However, you don't get the complete information about a lead at the start. That aside, how will you fill up fields when you don't have the information?
Let us take an example of concatenation of the first and last name fields and displaying the result in a custom field 'Full name'. For instance, if the First name is "David" and the last name is "Chester", the Full name field would be "David Chester". This function applies only if the field is 'not mandatory'. It takes effect only after the lead is saved.
This function is a versatile one, which you can use for merging and updating two fields into a single one on any module. The rest is up to your imagination.
You need to create a custom field named "Full name". This field is not normally available in the record creation form.
Getting started with the function:
- Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
- Provide a name for the function. For example: "Merge fields - Concatenate".
- Select the moduleto be associated as Leads. Add a description(optional).
- Copy the code given below.
- Click "Edit arguments".
- Enter the name as "leadId" and select the value as "Lead Id".
- Click Save & Execute Script.
- Save the changes.
This code is for the example of merging the first and last names of the lead and updating the result in the custom field "Full name".
leadDetails = zoho.crm.getRecordById("Leads", input.leadId);
first = ifnull(leadDetails.get("First_Name"),"");
last = ifnull(leadDetails.get("Last_Name"),"");
if ( first != "")
name = first + " " + last ;
name = last ;
update = zoho.crm.update("Leads",leadId.toLong(),mp);
- The code is zoho.crm._getRecordById for Version 1.0 of APIs.
- You can modify the code to make it work in any modules. Change the name of the module from 'Leads' to whichever module you prefer and update the code accordingly.
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!