Last active
February 27, 2020 06:43
-
-
Save CubeYogi/d1e462dc0cddcf4fd5206cb01ad74457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Replace the module API name | |
contact_module_name = "Contacts"; | |
deals_module_name = "Deals"; | |
//Replace the field API name | |
contact_full_name_field_name = "Full_Name"; | |
contact_description_field_name = "Description"; | |
contact_lead_source_field_name = "Lead_Source"; | |
contact_account_field_name = "Account_Name"; | |
common_id_field_name = "id"; | |
contact_owner_field_name = "Owner"; | |
deals_name_field_name = "Deal_Name"; | |
deals_description_field_name = "Description"; | |
deals_lead_source_field_name = "Lead_Source"; | |
deals_account_field_name = "Account_Name"; | |
deals_owner_field_name = "Owner"; | |
deals_stage_field_name = "Stage"; | |
deal_stage = "Contract Agreement"; | |
//Fetch the newly created contact entry using contact_id passed in the arguments | |
contact_entry = zoho.crm.getRecordById(contact_module_name,contact_id); | |
//Executes when contact entry is not enpty | |
if(contact_entry != null && contact_entry.size() > 0) | |
{ | |
//Executes when contact full name is not empty | |
if(contact_entry.get(contact_full_name_field_name) != null && contact_entry.get(contact_full_name_field_name) != "") | |
{ | |
//get the contact full name | |
contact_full_name = contact_entry.get(contact_full_name_field_name); | |
} | |
//Executes when contact description not empty | |
if(contact_entry.get(contact_description_field_name) != null && contact_entry.get(contact_description_field_name) != "") | |
{ | |
//get the contact description | |
contact_description = contact_entry.get(contact_description_field_name); | |
} | |
//Executes when contact lead source is not empty | |
if(contact_entry.get(contact_lead_source_field_name) != null && contact_entry.get(contact_lead_source_field_name) != "") | |
{ | |
//get the contact lead source | |
contact_lead_source = contact_entry.get(contact_lead_source_field_name); | |
} | |
//Executes when contact account name is not empty | |
if(contact_entry.get(contact_account_field_name) != null && contact_entry.get(contact_account_field_name) != "") | |
{ | |
//get the contact account id | |
contact_account_name = contact_entry.get(contact_account_field_name); | |
contact_account_id = contact_account_name.get(common_id_field_name); | |
} | |
//Executes when contact owner is not empty | |
if(contact_entry.get(contact_owner_field_name) != null) | |
{ | |
//get the contact owner id | |
contact_owner = contact_entry.get(contact_owner_field_name); | |
contact_owner_id = contact_owner.get(common_id_field_name); | |
} | |
//deal_map is created to add the fetched details into it | |
deal_map = Map(); | |
deal_map.put(deals_name_field_name,contact_full_name); | |
deal_map.put(deals_description_field_name,contact_description); | |
deal_map.put(deals_lead_source_field_name,contact_lead_source); | |
deal_map.put(deals_account_field_name,contact_account_id); | |
deal_map.put(deals_owner_field_name,contact_owner_id); | |
deal_map.put(deals_stage_field_name,deal_stage); | |
//Create new deal from the deal_map | |
create_deal = zoho.crm.createRecord(deals_module_name,deal_map); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment