I am currently trying to create a workflow rule to close the tasks still opens of the lost leads.
I tried the workflowrule and update the field but it does not work because they come from 2 different modules (task and lead).
So I tried to write a function that does not work also. Can you tell me what's wrong with that or anything else?
if(status.contains("Junk"))
{
leadIdStr = leadId.toString();
relatedTask = zoho.crm.v1.getRelatedRecords("Tasks","Leads",leadIdStr);
for each task in relatedTask
{
mapVariable = Map();
mapVariable.put("Status","Completed");
taskID = task.get("ACTIVITYID");
taskIdStr = taskID.toString();
updateTask = zoho.crm.v1.updateRecord("Tasks",taskIdStr,mapVariable);
}
}
if(status.contains("Junk"))
{
leadIdStr = leadId.toString();
relatedTask = zoho.crm.v1.getRelatedRecords("Tasks","Leads",leadIdStr);
for each task in relatedTask
{
mapVariable = Map();
mapVariable.put("Status","Completed");
taskID = task.get("ACTIVITYID");
taskIdStr = taskID.toString();
updateTask = zoho.crm.v1.updateRecord("Tasks",taskIdStr,mapVariable);
}
}