Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CubeYogi/0d60c5679d5f641cf0d18415653e4347 to your computer and use it in GitHub Desktop.
Save CubeYogi/0d60c5679d5f641cf0d18415653e4347 to your computer and use it in GitHub Desktop.
//Validating SO ID
if(input.sales_order_id != null)
{
//Getting SO entry
so_entry = zoho.crm.getRecordById("Sales_Orders", sales_order_id);
//Validating SO entry
if(!so_entry.isEmpty() && so_entry.containKey("Contact_Name"))
{
get_contact_map = so_entry.get("Contact_Name");
//Getting Contact ID
contact_id = get_contact_map.get("id");
//Validating Contact ID
if(contact_id != null && contact_id.trim() != "")
{
//Getting Contact entry
contact_entry = zoho.crm.getRecordById("Contacts", contact_id);
//Validating Contact entry
if(!contact_entry.isEmpty() && contact_entry.containKey("Email"))
{
//Getting Contact email
contact_email = contact_entry.get("Email");
//Validating contact email
if(contact_email != null && contact_email.trim() != "")
{
update_map = Map();
update_map.put("Email", contact_email);
//updating SO entry
update_so_entry = zoho.crm.updateRecord("Sales_Orders", sales_order_id, update_map);
//Validating SO response
if(!update_so_entry.isEmpty() && update_so_entry.containKey("status") && update_so_entry.get("status") == "error")
{
info "Error in updating SO: "+update_so_entry;
}
else
{
info "SO updated successfully";
}
}
else
{
info "Contact email is empty";
}
}
else
{
info "Contact entry is invalid";
}
}
else
{
info "Contact ID is empty";
}
}
else
{
info "SO entry is invalid";
}
}
else
{
info "SO ID invalid";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment