Skip to content

Instantly share code, notes, and snippets.

@CubeYogi
Created November 17, 2020 11:07
Show Gist options
  • Save CubeYogi/72d55ca7ce7ae5b0dcc94d28761cba00 to your computer and use it in GitHub Desktop.
Save CubeYogi/72d55ca7ce7ae5b0dcc94d28761cba00 to your computer and use it in GitHub Desktop.
//Validating Task ID
if(input.task_id != null)
{
//Getting task entry
task_entry = zoho.crm.getRecordById("Tasks",task_id);
//Validating Task entry
if(!task_entry.isEmpty())
{
task_map = Map();
//Getting task subject
get_subject = task_entry.get("Subject");
subject_formatted = "Followup for " + get_subject;
task_map.put("Subject", subject_formatted);
//Getting task owner
get_owner = task_entry.get("Owner");
//Validating Task owner
if(!get_owner.isEmpty())
{
owner_id = get_owner.get("id");
owner_map = Map();
owner_map.put("id", owner_id);
task_map.put("Owner", owner_map);
}
//Getting task due date
due_date = ifnull(task_entry.get("Due_Date"),zoho.currentdate);
task_map.put("Due_Date", due_date);
get_who_id = task_entry.get("Who_Id");
//Validating Task Contact ID
if(!get_who_id.isEmpty())
{
who_id = get_who_id.get("id");
who_id_map = Map();
who_id_map.put("id", who_id);
task_map.put("Who_Id", who_id_map);
}
get_what_id = task_entry.get("What_Id");
//Validating Task Entity ID
if(!get_what_id.isEmpty())
{
what_id = get_what_id.get("id");
what_id_map = Map();
what_id_map.put("id", what_id);
task_map.put("What_Id", what_id_map);
}
get_module = task_entry.get("$se_module");
//Validating Task Module
if(!get_module.isEmpty())
{
task_map.put("$se_module", get_module);
}
//Creating task entry
create_task = zoho.crm.createRecord("Tasks", task_map);
//Validating Task response
if(!create_task.isEmpty() && create_task.containKey("status") && create_task.get("status") == "error")
{
info "Error in creating Task: "+create_task;
}
else
{
info "Task created successfully";
}
}
else
{
info "Invalid Task entry";
}
}
else
{
info "Task ID invalid";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment