Solution: Deluge script for populating a lookup field when creating a new record in Zoho CRM

Solution: Deluge script for populating a lookup field when creating a new record in Zoho CRM

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!



    Access your files securely from anywhere











                            Zoho Developer Community





                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts





                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ




                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方