Copying a Lead to a new Custom Module (version that doesn't delete the previous lead)
Hello Zoho Forum,
I received a response earlier today regarding the use of deluge script to copy a record from the Leads module and enter it into a custom module. Unfortunately, it did neither and instead, deleted the record in the Leads module. Thankfully it was only sent to the recycle bin, so I was able to recover it.
Here is the script:
Setup -> Customization -> Modules ->Click on module name -> Links and Buttons -> create new button ->
1. Give button name -> choose view page -> choose Writing Custom functions
2. Give custom function name and click on 'free flow scripting'
3. copy and paste the below given code
- leadDetails = zoho.crm.getRecordById("Leads", input.leadId.toLong());
- name = ((ifnull(leadDetails.get("First Name"),"")) + " ") + ifnull(leadDetails.get("Last Name"),"");
- mp = map();
- mp.put("SMOWNERID", ifnull(leadDetails.get("SMOWNERID"),""));
- mp.put("CustomModule13 Name", ifnull(leadDetails.get("Last Name"),""));
- mp.put("First Name", ifnull(leadDetails.get("First Name"),""));
- mp.put("Company", ifnull(leadDetails.get("Company"),""));
- mp.put("Email", ifnull(leadDetails.get("Email"),""));
- mp.put("Phone", ifnull(leadDetails.get("Phone"),""));
- mp.put("Mobile", ifnull(leadDetails.get("Mobile"),""));
- mp.put("Lead Source", ifnull(leadDetails.get("Lead Source"),""));
- mp.put("Last Name", ifnull(leadDetails.get("Last Name"),""));
- mp.put("Fax", ifnull(leadDetails.get("Fax"),""));
- mp.put("Lead Status", ifnull(leadDetails.get("Lead Status"),""));
- mp.put("Address Line 1", ifnull(leadDetails.get("Address Line 1"),""));
- mp.put("Postal Code", ifnull(leadDetails.get("Zip Code"),""));
- mp.put("Address Line 2", ifnull(leadDetails.get("Address Line 2"),""));
- mp.put("County", ifnull(leadDetails.get("County"),""));
- mp.put("Description", ifnull(leadDetails.get("Description"),""));
- mp.put("Member", ifnull(leadDetails.get("Member"),""));
- mp.put("Sponsor", ifnull(leadDetails.get("Sponsor"),""));
- mp.put("Partnership Manager", ifnull(leadDetails.get("BDO AAM"),""));
- create = zoho.crm.create("CustomModule13", mp);
- custid = create.get("Id");
- del = getUrl("https://crm.zoho.com/crm/private/xml/Leads/deleteRecords?authtoken=99b9681696a406477bc5327985628a3f&scope=crmapi&id=" + input.leadId);
- openUrl( "https://crm.zoho.com/crm/EntityInfo.do?module=CustomModule13&id=" + custid, "parent window");
- return "Success";
4. click on 'edit arguments'
a) choose Lead Id - name it as 'leadId' and save
I need a version of this script that doesn't delete the record. One that merely copies the information from the lead record and input it to a custom module.