My use case: Create a new Invoice, using fields in the Potentials module in Zoho CRM - I want a button to do this. (Yes - I appreciate that this is not a normal use case, we have a simplified implementation of CRM that does not use Sales Orders etc)
Problem - it's pretty straightforward to populate normal fields, I came unstuck with lookups.
My lessons:
1. You need to make sure you use the API Name when referencing the field (found in the Setup -> Developer Space -> APIs -> CRM API).
2. You need to get the ID for the lookup you are populating
(I could have saved a lot of time if I'd found this info in the documentation or online forums. In the end, I got my help via a support request. The documentation might not be perfect, but the Zoho support for Deluge is really helpful!)
Example:
Creating a button in Potentials to create a new Invoice, using a deluge script... (we call our Potentials module 'Projects')
- I have mapped pId as Project Id
- I want the Contact Name, Potential Name and Account Name in the Invoice (ie as lookups)
Key items from my Deluge:
respMap = zoho.crm.getRecordById("Potentials",pId.toLong()); // gets the record fields for the given
pId
p_CustomerName = ifnull(respMap.get("Contact_Name"),"").get("id"); // gets the id for the Contact
p_AccountName = ifnull(respMap.get("Account_Name"),"").get("id"); // gets the id for the Account
paramap = Map(); // create map translation for fields to go into Invoice
paramap.put("Subject",'INV ' + respMap.get("Deal_Name")); // example of straightforward field mapping{ie paramap.put(to field using API Name in Invoice, from field using API Name in Potential)
paramap.put("Account_Name",p_AccountName); // field mapping for Account_Name (my API Name for Account Name)
paramap.put("Contact_Name",p_CustomerName); // field mapping for Contact_Name (my API Name for Contact Name)
paramap.put("Related_Project",pId); // field mapping for Related_Project (my API Name for Potential Name)
paramap.put("Status",'Created'); // sets Status to 'Created'
// further field mappings (making sure I use API Names)
createResp = zoho.crm.create("Invoices",paramap); // create invoice
I trust this helps!