Concatenate two fields — (Combining two field values onto a third field)

Concatenate two fields — (Combining two field values onto a third field)

There are times when it is necessary to combine two separate field values into a single field. In such instances, we can concatenate two separate fields from the same module with the use of a custom function. For example, in one of the modules, we might want to concatenate First and Last names and display them as a single field called Name. This is just an example; you may apply the same custom function to any two fields you like.

Pre-requisites :
Create a field that displays the concatenated result. This field is not available by default so you have to add it to the page layout manually.
Go to Set Up > Modules and fields > Select the required module > Choose the layout you need to edit.


To create a custom function :
  1. Go to Setup > Actions > Functions > Configure Function > Write your own
  2. Provide a Function name, Display name and select the module as per required.
  3. Click on edit arguments, and map the required arguments. In this case, Lead ID, Lead first name and last name are required.
  4. Type the below given script and save.

Code :
leadDet = zoho.crm.getRecordById("Leads",Lead_id);
map = Map();
map.put("Name1",Lead_first_name + ' ' + Lead_last_name);
con = zoho.crm.updateRecord("Leads",Lead_id.tolong(),map);
info map;
info con;
Adding the custom function to workflow :
The key benefit of including a custom function in a workflow is that it can be utilized for any module. We integrate workflow rules, as well as any additional buttons and links, into every custom function we design.

Steps :
  1. Go to Set Up > Automation > Workflow rules > +Create Rule.
  2. Enter the required details and select the desired module.
  3. Select "On a record action" in the "When do you want to execute this rule?".
  4. Select "Create".
  5. Select the Condition as "All Leads".
  6. Choose "Function" from Instant Actions.
  7. Choose the desired function created by the user and click 'Associate'. In this the case the function name 'Concatenate'.
  8. Click Save.

Execution :
Fill out the form with all of the required information. When a new record is produced, the workflow rule is invoked. You can now check the leads module, and the results will be reflected. The 'Name' field combines the first and last name fields.



Other examples :
This custom function can also be used to concatenate additional fields.
1) For example, creating a title based on any of the other parameters. More than two fields can also be concatenated. In this case, a design firm follows a typical naming convention for a field called "Title". This includes their first name, company name, and the service (design) they selected. Fill up the required information. The title field has been left blank since it will be filled in automatically using the required fields.



2) Consider an educational institution that keeps track of student and staff information. The student's name and graduation year are required fields on the application. They usually pertain to different fields. What if the institute insists on having both displayed in the same field? In addition, the institute wants that field to appear in the business card view. This concatenate custom function can also handle this type of case.

Step 1 : Create fields accordingly, in this case 'Year of Graduation' field is added.



Step 2 : Write custom function that concatenate both the fields. Add the created function to workflow rules. Create a new field 'Students detail' which will display the concatenated result.
Code :
Stud_yop = zoho.crm.getRecordById("Contacts",cont_id);
map = Map();
map.put("Student_details",cont_name + ' ' + cont_yop);
yop = zoho.crm.updateRecord("Contacts",cont_id.tolong(),map);
info yop;
info Stud_yop;
Step 3 : Add the result field 'Student details' in business card view.
Step 4 : Create workflow rules for the function.

Note : We can also add 'last name' in the concatenation.


    • Related Articles

    • How do I combine two single line fields using a formula field?

      You can use Zoho CRM formula fields to set up fields that can populate dynamically calculated data based on the values returned from other standard or custom fields. For example, you want to combine the First Name and Last Name fields in ...
    • Auto-update multiple fields with same values.

      When you consider the data that you add in Zoho CRM, many a time you may want to enter the same value for two different fields in a record. Some of these scenarios are as follows : If the customer only has one phone number, the information in the ...
    • Does marking a field as PHI (Personal Health Information) automatically encrypt it?

      No, marking a field as PHI only enables the system to identify that the values present in it contain personal health information of an individual. As an additional layer of security, these fields can be encrypted separately. While this isn't ...
    • Send automatic notifications to the third-party providers

      Edition: All editions | Industry: Travel | Features: Workflow Rules Scenario Zylker Travels offers various tour packages to its customers ranging from adventure trips, family outings, destination holidays and weekend getaways. Their customer flow ...
    • What kind of encryption is added to the PHI fields?

      Fields that contain personal health information of individuals can be encrypted to prevent unauthorized access. Once encrypted, the fields are added with EAR. Encryption at Rest Refers to data that is encrypted when it is stored (not moving) — either ...