Function-9: Concatenate two fields into a single one.

Function-9: Concatenate two fields into a single one.



Welcome back everyone!

Last week, we learnt how to assign leads based on your sales reps' shift timings. This week, let's look at a custom function that allows you to combine the information in two fields and present them in a single field.

Business scenario:

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.

Pre-requisite:
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 custom function:

  1. Go to Setup > Automations > Actions > Custom Functions > Configure Custom Function > Write your own .
  2. Provide a name for the custom function. For example: “Merge fields”. Add a description(optional).
  3. Select the module as Leads. Add a description(optional).
  4. Click “ Free flow scripting ”.
  5. Copy the code given below.
  6. Click “ Edit arguments ”.
  7. Enter the name as “ leadId ” and select the value as “ Lead Id ”.
  8. Save the changes.
The script:

Code for Version 2.0 API:
 
This code is for the example of merging the first and last names of the lead and updating the result in the custom field "Lead_Full_Name" custom field. 

leadDetails = zoho.crm.getRecordById("Leads", input.leadId.toLong()); 
first = ifnull(leadDetails.get("First_Name"),""); 
last = ifnull(leadDetails.get("Last_Name"),""); 
if ( first != "") 

name = first + " " + last ; 

else 

name = last ; 

mp=map(); 
mp.put("Lead_Full_Name",name); 
update = zoho.crm.update("Leads",leadId.toLong(),mp); 
info mp; 
info update; 

Code for Version 1.0 API:

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" custom field.

leadIdStr=input.leadId.toString();
leadDetails = zoho.crm.getRecordById("Leads", input.leadId);
first = ifnull(leadDetails.get("First Name"),"");
last = ifnull(leadDetails.get("Last Name"),"");
if ( first != "")
{
name = first + " " + last ;
}
else
{
name = last ;
}
mp=map();
mp.put("Full Name",name);
update = zoho.crm.updateRecord("Leads",leadIdStr,mp);
info mp;
info update;

Note:

  • 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 me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful. Do check out other custom functions shared in this serieshere.

See you all next week with another interesting custom function. Ciao!

Update: As you must be aware, API V1.0 will be deprecated and support for version 1.0 API will be available only till Dec 31, 2018. Version 1.0 compatible Functions will continue to work until Dec 31, 2019. You're advised to migrated to API Version 2.0 at the earliest. Check this announcement for more. We've updated the post to include the Version 2.0 compatible Function.




                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation
                                        • Sticky Posts

                                        • ZUG (Zoho User Group) In-person Meetups - Learn, Share, and Discuss All Things Zoho

                                          Hi, We hope you are all doing well. We are excited to announce the second leg of our in-person Zoho User Group (ZUG) meetups in your region. A quick update: Our first leg of meetups in 2024 reached completion, and Zoho experts had the opportunity to meet
                                        • Tip #35 - On using Kanban View in Zoho CRM

                                          Hi folks,  It's that time of the week again, and I am back with a quick tip about using Kanban View in Zoho CRM. If you think you missed any of our previous weeks' tips, you can read them here.  Tip #35 - On using Kanban View in Zoho CRM You deal with so many records in CRM every single day! When you click open each module in Zoho CRM, you have hundreds of records, each in various stages of your sales pipeline. Wouldn't it be cool if you had them all sorted automatically without having to filter
                                        • ZUG (Zoho User Group) In-person Meetups - Learn, share and discuss all things Zoho

                                          Hi, Hope you all are well. We're excited to announce our second leg of in-person Zoho User Group (ZUG) meetups in your region. A quick update - Our first leg of meetups in 2024 progressed and reached completion smoothly, where Zoho experts had the opportunity
                                        • ZUG (Zoho User Group) In-person Meetups - Learn, share and discuss all things Zoho

                                          A big warm hello to the Zoho Community, and Happy new year to all of you! We're thrilled to let you know that our ZUG Meetups for 2024 have almost begun, and we can't wait for you to be a part of them. We have some interesting topics in store for this
                                        • Cloning Email Templates across modules in Zoho CRM.

                                          The option of cloning email templates across modules has been a long standing feature request from the Community. Thank you all for being so patient with us. We are happy to inform you all that this enhancement has been rolled out. Just in case you haven't noticed it already, cloning email templates is possible now! Cloning is useful because it cuts down the hassle of having to create the same email templates again for different modules. Here are the steps: Navigate to Settings---> Customization--->Templates


                                        Manage your brands on social media



                                              Zoho TeamInbox Resources

                                                Zoho DataPrep Resources



                                                  Zoho CRM Plus Resources

                                                    Zoho Books Resources


                                                      Zoho Subscriptions Resources

                                                        Zoho Projects Resources


                                                          Zoho Sprints Resources


                                                            Qntrl Resources


                                                              Zoho Creator Resources


                                                                Zoho WorkDrive Resources



                                                                  Zoho Campaigns Resources

                                                                    Zoho CRM Resources

                                                                    • CRM Community Learning Series

                                                                      CRM Community Learning Series


                                                                    • Tips

                                                                      Tips

                                                                    • Functions

                                                                      Functions

                                                                    • Meetups

                                                                      Meetups

                                                                    • Kbase

                                                                      Kbase

                                                                    • Resources

                                                                      Resources

                                                                    • Digest

                                                                      Digest

                                                                    • CRM Marketplace

                                                                      CRM Marketplace

                                                                    • MVP Corner

                                                                      MVP Corner

                                                                    





                                                                    




                                                                        Design. Discuss. Deliver.

                                                                        Create visually engaging stories with Zoho Show.

                                                                        Get Started Now