Add leads to campaign records at the click of a button
Business scenario
The Campaigns module in Zoho CRM helps you plan and run promotional campaigns effectively. The campaign record centralizes all the related leads, contacts and deals associated with the campaign. It helps you stay on top of cost, revenue, and the revenue pipeline of all the deals associated with the campaign. Measuring ROI of sales and marketing campaigns becomes much more simpler with effective use of Campaigns.
Sounds easy, right? However, the tricky part is ensuring that your users update the related records in time. This ensures that the revenue accrued and the revenue pipeline reflect properly in the campaign record. This lets you take corrective actions if the campaigns don't perform as expected. Let's say you are running a year-end discount sale targeting customers from specific cities. As the specifications vary based on the city and product, you create multiple campaigns to measure its effectiveness. At the entry level, your users are tasked with two CRM activities - creating the lead records and linking the lead record with their relevant campaign. Business processes should only serve to enhance sales productivity and not derail it :) The custom function shared this week addresses this requirement effectively. It links the lead and campaign records at the click of a button and eliminates the need to link manually every time a lead is created.
The button is placed in the list view page of Leads module. This lets you link multiple leads to a campaign record easily.
Pre-requisites
- Create and link the button with the custom function as detailed in the "Getting started with the custom function" section below.
- To use this custom function for multiple campaigns, clone this custom function and link it with new buttons. Ensure you update the campaign id's accordingly.
- To link multiple lead records to a campaign, just select the leads from the list view of Leads module and click on the respective campaign button.
Getting started with the function
- Go to Setup > Customization > Modules > Deals > Links and Buttons > + New Button.
- Provide a name for the button. For example: "[The campaign name]". Add a description(optional).
- Select the placement of the button as View Page.
- Select the action to be performed as "Writing Function".
- Copy the code given below.
- Click "Edit Arguments".
- Enter the name as "leadId" and select the value as "Lead Id".
- Create a new argument with the name as "Authtoken" and select the value as "Auth token".
- Click Save & Execute Script.
- Save the changes.
- Select the profiles who can view this button.
- Click Save.
The Code
leadIdsList = input.leadId.toList("|||");
campid = "zzzzzzzzzzzzz";
for each leadIdStr in leadIdsList
{
mp=map();
mp.put("CAMPAIGNID",campid.toLong());
resp = zoho.crm.updateRelatedRecord("Campaigns",campid.toLong(),"Leads",leadIdStr.toLong(),mp);
info resp;
}
return "success";
Note:
- The above code works only for API V2.0 and not the previous version.
- The Campaigns module in Zoho CRM is different from Zoho Campaigns. Zoho Campaigns is a separate email marketing application from Zoho.
- Change the 'zzzzzzzzzzzzz' to the ID of the campaign. Associating a campaign with a lead requires the campaign ID and not the campaign name.
- The ID can be found in the URL of the Campaign record. Take a look at the screenshot below for more details.
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!