Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CubeYogi/afc9c6d5e045f6eabdfae4a86cbbb654 to your computer and use it in GitHub Desktop.
Save CubeYogi/afc9c6d5e045f6eabdfae4a86cbbb654 to your computer and use it in GitHub Desktop.
//Validating account ID
if(account_id != null)
{
//Getting Account entry
account_entry = zoho.crm.getRecordById("Accounts",account_id);
//Validating account response
if(!account_entry.isEmpty() && account_entry.containKey("Membership_status"))
{
//Getting Account Owner entry
account_value = account_entry.get("Membership_status");
//Validating account owner response
if(account_value != null && account_value.trim() != "")
{
//Getting Contact Entries
contact_entries = zoho.crm.getRelatedRecords("Contacts","Accounts",account_id);
//Validating Contacts response
if(!contact_entries.isEmpty())
{
for each contact in contact_entries
{
//Getting Contact ID
contact_id = contact.get("id");
//Validating Contact ID
if(contact_id != null && contact_id.trim() != "")
{
//Putting owner in the update map
update_map = Map();
update_map.put("Membership_status",account_value);
//Updating Contact Entry
update_contact = zoho.crm.updateRecord("Contacts",contact_id,update_map);
info update_contact;
if(!update_contact.isEmpty() && update_contact.containKey("status") && update_contact.get("status") == "error")
{
info "Error in updating Contact: " + update_contact;
}
else
{
info "Contact updated successfully";
}
}
else
{
info "Contact ID is empty";
}
}
}
else
{
info "Contacts reponse empty";
}
}
else
{
info "Account value is empty";
}
}
else
{
info "Invalid Account response";
}
}
else
{
info "Invalid Account ID passed";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment