A Creator script that loads related records from Zoho CRM and adds as values to a picklist (radio) field on Zoho Creator, then gets related info by creating maps and storing them in multi-line fields in Creator.
Zoho Creator has a nifty little feature that enables you to add values to a picklist (radio) field via Deluge. With the function, you can fetch records from Zoho CRM and dynamically populate them as field values in the Creator picklist field. Simultaneously, by creating map strings (key-value pairs) containing relevant info based on the picklist to add to multi-line fields, we can easily get the related info to execute certain actions upon form submission.
Staffs of Company A wants a Creator Form, accessible from the Contacts module in CRM. In that Form, they would like to be able to select one of the contacts’s Course Enrollment (another module), then reassign that course’s Program Coordinator (another module) for the student – there are 3 modules at play here.
Create a Custom Button on CRM in the desired module
url = "?Contact_ID=" + contactid; openUrl(url,"new window"); return "";
The following script needs to be written on load of the Creator form.
Get the related Course Enrollments from the Contact ID, then use a for loop
to iterate though each Course Enrollments to get the name and ID. In the loop
, use the ui.add
function in Creator to populate the Course Enrollment names to the “Which Course Enrollment would you like to Update?” radio field. String manipulation is applied to create the name and ID map to add to the Course Enrollment Name and ID Map multi-line field.
courseenrollments = zoho.crm.getRelatedRecords("Student_Enrolled","Contacts",input.Contact_ID); string = ""; for each c in courseenrollments { input.Which_Course_Enrollment_would_you_like_to_Update:ui.add(c.get("Name")); string = string + "\"" + c.get("Name") + "\"" + ":" + c.get("id") + ","; } mapstring = "{" + string + "}"; mapstring = mapstring.removeLastOccurence(","); input.Course_Enrollment_Name_and_ID_Map = mapstring;
Get all Program Coordinators from CRM, then use a for loop
to iterate though each Program Coordinator to get the name and ID. In the loop
, use the ui.add
function in Creator to populate the Program Coordinator names to the “Who should become the new Program Coordinator?” radio field. String manipulation is applied to create the name and ID map to add to the Program Coordinator Name and ID Map multi-line field.
progs = zoho.crm.getRecords("Program_Coordinators"); string = ""; for each p in progs { input.Who_should_become_the_new_Program_Coordinator:ui.add(p.get("Name")); string = string + "\"" + p.get("Name") + "\"" + ":" + p.get("id") + ","; } mapstring = "{" + string + "}"; mapstring = mapstring.removeLastOccurence(","); input.Program_Coordinator_Name_and_ID_Map = mapstring;
An on submission Creator script is to be written to execute the actions (the submission actions script is arbitrary and will not be elaborated here). Instead, here are tips on how to use the map string field that you have created in the on load script above.
To convert the map string field values to map, use the toMap()
function.
enidmap = input.Course_Enrollment_Name_and_ID_Map.toMap(); progidmap = input.Program_Coordinator_Name_and_ID_Map.toMap();
Now that they are maps, you can easily use a .get()
function to get the information to execute the actions that you need.
enrollmentid = enidmap.get(input.Which_Course_Enrollment_would_you_like_to_Update).toLong(); progid = progidmap.get(input.Who_should_become_the_new_Program_Coordinator);
Click here to copy these scripts. For more Zoho-wizardry, check out our GitHub page.
When scripting, ask yourself this question – will this value ever be null? If it’s a yes, that’s a place for a null check! Here are 3 tips and best practices to help you kickstart the habit....
Learn to create a customized inventory report with Zoho Analytics. This tutorial contains a link to our GitHub page for SQL code that will help with your table creations....
How nice would it be if you could, at the press of a button, send clients an email w/a Zoho Books invoice? Replete with “Pay Now” buttons that link to PayPal/Stripe/other payment gateways?...
Whether you work primarily out of CRM or the Zoho Finance Suite, you can use Analytics to build commissions dashboards. This involves some fairly simple SQL code....
If you are an inventory manager, this blog post could change your life. If you are not, it will at least teach you how to build some wicked inventory tracking for your business....
Convert fields, related activities, attachments, notes and more from one record to another across modules via custom function....