How to perform action when lead has no campaigns

How to perform action when lead has no campaigns

I am trying to write a function that looks to see if a lead has had any campaigns assigned to it and if so, change the status to "Attempted to Contact". The code I am using is below:

relatedCampaign = zoho.crm.getRelatedRecords("Campaigns","Leads",LeadID);
info relatedCampaign;
if(relatedCampaign != null)
{
info "found something";
LeadUpdateMap = Map();
LeadUpdateMap.put("Lead_Status","Attempted to Contact");
updateResp = zoho.crm.updateRecord("Leads",LeadID,LeadUpdateMap);
}
else
{
info "nothing here";
LeadUpdateMap = Map();
LeadUpdateMap.put("Lead_Status","Not Contacted");
updateResp = zoho.crm.updateRecord("Leads",LeadID,LeadUpdateMap);
}

Unfortunately, in testing the leads always end up in the "found something" category instead of detecting that there are no campaigns (even if there are none.

Any help is appreciated!


      • Sticky Posts

      • How to Add Users to your Organization in ZohoMail?

        A better clarity so you can create other users to start using Zoho Mail. You can directly Add Users from the Control Panel to your Organization. You can invite users with the existing email address. If the person (user) already uses ZohoCRM, then you can import users from Zoho CRM. You can also import them using a .csv file. (if you are planning to add them in Bulk)  In this topic, We will be discussing on how to Add and Invite users only.  The Import options are self explanatory. ____________________________________________________________________________________________________________