Welcome to Portal
Hey Kellian,
Thanks for trying to create the custom function on your own. Brownie points for trying! :)
Go to Setup -> Automation -> Actions -> Custom Functions -> Configure Custom Function -> Write your own ->
1) Choose module as 'Leads'
2) Give a custom function name of your choice
3) Copy and paste the code below
relatedTask = zoho.crm.getRelatedRecords("Tasks","Leads",leadId.toLong());
for each task in relatedTask
{
mapVariable = Map();
mapVariable.put("Status","Completed");
updateTask = zoho.crm.updateRecord("Tasks", task.get("id"),mapVariable);
info updateTask;
}
4) Click on 'edit arguments' (above the box where you pasted this code)
a) Choose Leads id (from drop down list) - name it as 'leadId' and save.
5) Click on Save and then we have to associate a workflow for the Leads module.
Setup --> Automation --> Workflow Rules --> + Create Rule --> Module Leads & rule name of your choice --> When? (on edit, I presume, since you'll be changing the status of the lead) Condition 1? (when lead status is lost lead) Instant Action? (the function you just created) --> Save.
Hope this helps.
Do keep testing it out and sharing your thoughts. Love to hear them.
Cheers!
Hello Andy,
Thank you very much for the function. I followed your steps and it works wonderfully for my lost leads.
I also need a function that would mark certain tasks completed when a Lead/Potential Status is changed. How could I do that, please?
Thank you very much for your time.
Cheers,
Sagat
Subscribe to receive notifications from this topic.
Hi Marvin,
You can refer to the below sample code, this will close the junk lead tasks.
Arguments:
lead id and name it as leadId
if(status.contains("Junk"))
{
relatedTask = zoho.crm.getRelatedRecords("Tasks","Leads",leadId.toLong(),1);
for each task in relatedTask
{
mapVariable = Map();
mapVariable.put("Status","Completed");
updateTask = zoho.crm.updateRecord("Tasks",task.get("id"),mapVariable);
info updateTask;
}
}
Check and let us know if you have any further clarification.