A simple and effective Deluge script that lets you clone records (with or without some changes).
Here's a quick, easy, no-frills method to clone/duplicate a Zoho CRM record via Deluge. The idea is to get the full JSON map of the record, make changes to the record map (if necessary), and create the new record.
We use the getRecordsbyId
Deluge task to get the complete map of the record information.
record = zoho.crm.getRecordById("CRM_Module_Name","Record_ID");
info record;
We can modify the record data by using the put
and remove
function.
In order to change the value of a key, use the put
function to assign a new value to the key.
For example, if your new record is to be called "{Record Name} - Copy", this is how the script would look like.
record.put("Name",recordData.get("Name") + " - Copy";
You can replace the value of as many keys as you want.
record.put("Stage","Closed Won");
record.put("Closing Date",today);
You can also reassign lookup fields by reassigning the value of the lookup map with the new ID (the ID alone is sufficient).
record.put("Account_Id",{"id","Replacement_Account_ID"});
If you want to exclude certain fields from the cloned record, simply remove the key from the record map using the remove
function.
record.remove("Currency");
Once you are done modifying the record map, create the new "cloned" record using the createRecord
Deluge task with the record map.
newrecord = zoho.crm.createRecord("CRM_Module_Name", record);
info newrecord;
Note: When creating clone/duplicate records, keep in mind that you may have unique field(s) set up in your module. To successfully create the cloned record, you need to make sure that you modify the value of the field(s).