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.
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();
.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);
Book a free 30-minutes consultation with a Zoho expert or send us an email