Copying a Lead to a new Custom Module (version that doesn't delete the previous lead)

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

  1. leadDetails = zoho.crm.getRecordById("Leads", input.leadId.toLong());
  2. name = ((ifnull(leadDetails.get("First Name"),"")) + " ") + ifnull(leadDetails.get("Last Name"),"");
  3.  mp = map();
  4.  mp.put("SMOWNERID", ifnull(leadDetails.get("SMOWNERID"),""));
  5.  mp.put("CustomModule13 Name", ifnull(leadDetails.get("Last Name"),""));
  6.  mp.put("First Name", ifnull(leadDetails.get("First Name"),""));
  7.  mp.put("Company", ifnull(leadDetails.get("Company"),""));
  8.  mp.put("Email", ifnull(leadDetails.get("Email"),""));
  9.  mp.put("Phone", ifnull(leadDetails.get("Phone"),""));
  10.  mp.put("Mobile", ifnull(leadDetails.get("Mobile"),""));
  11.  mp.put("Lead Source", ifnull(leadDetails.get("Lead Source"),""));
  12.  mp.put("Last Name", ifnull(leadDetails.get("Last Name"),""));
  13.  mp.put("Fax", ifnull(leadDetails.get("Fax"),""));
  14.  mp.put("Lead Status", ifnull(leadDetails.get("Lead Status"),""));
  15.  mp.put("Address Line 1", ifnull(leadDetails.get("Address Line 1"),""));
  16.  mp.put("Postal Code", ifnull(leadDetails.get("Zip Code"),""));
  17.  mp.put("Address Line 2", ifnull(leadDetails.get("Address Line 2"),""));
  18.  mp.put("County", ifnull(leadDetails.get("County"),""));
  19.  mp.put("Description", ifnull(leadDetails.get("Description"),""));
  20.  mp.put("Member", ifnull(leadDetails.get("Member"),""));
  21.  mp.put("Sponsor", ifnull(leadDetails.get("Sponsor"),""));
  22.  mp.put("Partnership Manager", ifnull(leadDetails.get("BDO AAM"),""));
  23.  create = zoho.crm.create("CustomModule13", mp);
  24.  custid = create.get("Id");
  25.  del = getUrl("https://crm.zoho.com/crm/private/xml/Leads/deleteRecords?authtoken=99b9681696a406477bc5327985628a3f&scope=crmapi&id=" + input.leadId);
  26.  openUrl( "https://crm.zoho.com/crm/EntityInfo.do?module=CustomModule13&id=" + custid, "parent window");
  27.  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.