continfo = zoho.crm.getRecordById("Contacts", contId.toLong());
mp = map();
mp.put("Last_Name",continfo.get("Last_Name"));
mp.put("Owner",continfo.get("Owner").get("id"));
mp.put("First_Name",ifnull(continfo.get("First_Name"),""));
acctname = ifnull(continfo.get("Company_of_Employment"),"");
if(acctname != "")
{
mp.put("Account_Name",acctname.get("id"));
}
mp.put("Lead_Source",ifnull(continfo.get("Lead_Source"),""));
mp.put("Description",ifnull(continfo.get("Description"),""));
mp.put("Email",ifnull(continfo.get("Email"),""));
mp.put("The_un",ifnull(continfo.get("industry"),""));
mp.put("Lead_Rating_5_Being_the_Strongest",ifnull(continfo.get("Lead_Rating_5_Being_the_Strongest"),""));
mp.put("LinkedIn",ifnull(continfo.get("LinkedIn"),""));
mp.put("Mobile",ifnull(continfo.get("Mobile"),""));
mp.put("Other_Phone",ifnull(continfo.get("Other_Phone"),""));
mp.put("Other_Zip",ifnull(continfo.get("Zip_Code"),""));
mp.put("Other_State",ifnull(continfo.get("State"),""));
mp.put("Other_Street",ifnull(continfo.get("Street"),""));
create = zoho.crm.create("Leads", mp);
info create;
// Notes
RelatedNotes = zoho.crm.getRelatedRecords("Notes", "Contacts", input.contId.toLong());
for each note in RelatedNotes
{
notemap = Map();
notemap.put("Parent_Id",create.get("id"));
notemap.put("Note_Content",note.get("Note_Content"));
notemap.put("Note_Title",note.get("Note_Title"));
notemap.put("se_module","Leads");
notecreate = zoho.crm.create("Notes",notemap);
}
// Tasks
reltasks = zoho.crm.getRelatedRecords("Tasks","Contacts",input.contId.toLong());
for each task in reltasks
{
taskmap = Map();
taskmap.put("What_Id",create.get("id"));
taskmap.put("$se_module","Leads");
taskmap.put("Who_Id","");
updatetask = zoho.crm.update("Tasks",task.get("id"),taskmap);
info updatetask;
}
// Events
relevents = zoho.crm.getRelatedRecords("Events","Contacts",input.contId.toLong());
for each events in relevents
{
eventmap = Map();
eventmap.put("What_Id",create.get("id"));
eventmap.put("$se_module","Leads");
eventmap.put("Who_Id","");
updateevent = zoho.crm.update("Events",events.get("id"),eventmap);
info updateevent;
}
// Calls
relcalls = zoho.crm.getRelatedRecords("Calls","Contacts",input.contId.toLong());
for each call in relcalls
{
callmap = Map();
callmap.put("What_Id",create.get("id"));
callmap.put("$se_module","Leads");
callmap.put("Who_Id","");
updatecall = zoho.crm.update("Calls",call.get("id"),callmap);
info updatecall;
}
// Campaigns
relatedcamp = zoho.crm.getRelatedRecords("Campaigns","Contacts",contId.toLong());
for each camp in relatedcamp
{
mp=map();
mp.put("CAMPAIGNID",camp.get("id"));
resp = zoho.crm.updateRelatedRecord("Campaigns",camp.get("id").toLong(),"Leads",create.get("id"),mp);
info resp;
}
// Products
relatedproducts = zoho.crm.getRelatedRecords("Products","Contacts",contId.toLong());
for each product in relatedproducts
{
mp=map();
mp.put("PRODUCTID",product.get("id"));
resp = zoho.crm.updateRelatedRecord("Products",product.get("id").toLong(),"Leads",create.get("id"),mp);
info resp;
}
//Attachments
relatedrcords = zoho.crm.getRelatedRecords("Attachments","Contacts",contId.toLong());
attachid = List();
for each ele in relatedrcords
{
attachementId = ele.get("id");
attachid.add(attachementId);
}
for each ele in attachid
{
downloadFile = invokeurl
[
type: GET
connection : "convert_to_lead"
];
resp = zoho.crm.attachFile("Leads",create.get("id"),downloadFile);
info resp;
}
deleteResp = zoho.crm.invokeConnector("crm.delete",{"module":"Contacts","id":contId});
info deleteResp;
Also here is a screenshot of my attempt to argument map:
Thank you.