Hello Everyone!
Today marks a significant milestone – our 100th Kaizen post! We are beyond thrilled to have shared this journey with you! Your engagement, feedback, and support have been pushing us forward. Thank you!
We recently asked you for your feedback on our Kaizen series through this
form, and we are so grateful for the thoughtful responses we received. We asked, and you answered! We are excited to share our answers to some of your questions in our 100th Kaizen post.
1. Please add a function to get the API Name of the field that caused the onChange in the page processing. For example, if I want to do an automatic string modification process, I cannot get the field name changed by the user, so I have to do the process for all fields, which is slow. That said, setting it up in "Item Processing" is difficult if there are a lot of items and is not very maintainable.
To get the API Name of the field that cause onChange event in a page, you can simply use the field_name argument.
To get the API Name of the field that cause onChange event in a page, you can simply use the field_name argument.
In
Client Script, based on the event that you configure, you can use the appropriate arguments while you code the script.
Click here to know the arguments available for various event types.
Now let us execute the above log script for create page of Leads module using the
Run component.
In the below gif, you can see that for every field that the user enters data, the log statement will give the api name of the corresponding field updated by the user.
Note:
The field_name argument for onChange Page event is available for Create, Clone, Edit, Create(Wizard), Edit(Wizard), Detail Page(Canvas)
At Zylker, a manufacturing company, consider that you want to achieve the following using Client Script. In the create page of Orders module, whenever the field Product is Ignition box, Category should get auto-populated as Ignition System. If the Product is Voltmeter then Category should get auto-populated as Gauges and meters.
Whenever the user edits or adds the Phone Number with length less than 10, display an error message near the field. If the field Country is India, the maximum number of digits that the user can enter the field Phone Number should be limited to 10.
Instead of creating 3 separate Client Scripts with field event , you can create a single Client Script with onChange Page event.
You can use the "field_name" argument to check which field was changed by the user.
Here is the Script.
switch (field_name) { case 'Product': var product_name = ZDK.Page.getField('Product').getValue(); var category_field = ZDK.Page.getField('Category'); // requirement - 1 if (['Ignition box', 'Ignition coil', 'Spark plug'].includes(product_name)) { // Populate value for picklist field 'Category' based on the condition category_field.setValue("Ignition system"); ZDK.Page.getField('Number_of_Boxes').setMandatory(true); // requirement - 2 } else if (['Speedometer', 'Odometer', 'Voltmeter','].includes(product_name)) { // Populate value for picklist field 'Category' based on the condition category_field.setValue('Gauges and meters'); } break;
case 'Phone_Number': var phone_field = ZDK.Page.getField('Phone_Number'); if (phone_field.getValue().length < 10) { phone_field.showError('Enter a valid phone number'); // requirement - 4 } break;
case 'Country': ZDK.Page.getField('Phone_Number').setMaxLength(10); break; case 'Category': if (ZDK.Page.getField('Category').getValue() === 'Ignition system') { ZDK.Page.getField('Number_of_Boxes').setMandatory(true); // requirement - 2 when category is changed in ui } break; }
|
In the above script, based on the field updated by the user, execution will happen.
2. I would like to be able to retrieve sub-form records with COQL.
Subform is a data section embedded in the primary form to collect details related to the parent record. It helps in maintaining multiple records under a single parent record. These subform records cannot be fetched via the parent module in the
Query API. Since subforms are treated as individual modules, you should state their API names to access their records or fields. Consider a manufacturing company, Zylker, which uses Zoho CRM for effective maintenance of customer relationships. The suggestions and feedback from each of their clients are tracked with the help of a subform called Client Review in the Accounts module.
Consider a manufacturing company, Zylker, which uses Zoho CRM for effective maintenance of customer relationship. The suggestions and feedback of each of their clients is tracked with the help of a subform called Client Review in the Accounts module.
Now the Manager wants to fetch the suggestions from all the Accounts. Let us see how he can achieve this using COQL API.
Step 1: Make a
GET Modules metadata API call to get the api_name of the subform.
Step 2: Using the api_name of the subform, make a
GET Fields metadata API call to get the api_name of the fields in the subform.
Step 3: Use the api_name of subform and subform fields to construct a query.
{ "select_query": "select Suggestions from Client_Review where Suggestions is not null" } |
Step 4: Use this query in the COQL API.
Request URL: {api-domain}/crm/{version}/coql
Request Method: POST
Scope: To access COQL API, you need to pass two scopes - ZohoCRM.coql.READ and ZohoCRM.modules.all. You can also use ZohoCRM.modules.{module_name}.{operation_type} in the place of ZohoCRM.modules.all.
Request Body :
{ "select_query": "select Suggestions from Client_Review where Suggestions is not null" } |
Response :
Using the parent record id, you can fetch the subform records related to a particular Account. Following is the request body to fetch the subform details particular to a parent record,
{ "select_query": "select Suggestions, Feedback from Client_Review where ((Parent_Id=5545974000003933016) and ((Suggestions is not null) and (Feedback is not null)))" } |
This query will fetch all the subform records of the specified record whose Suggestions and Feedback fields are not null as shown below.
3. I want to discuss Subform in Zoho CRM. Can the user filter subform record in Deal or Lead?
We can filter the records that have subform fields in them using COQL. Consider the example of the above manufacturing company, Zylker. The manager wants to fetch the details of those records in the Accounts modules that have Client Review details. This can be achieved by the following COQL query.
{ "select_query":"select Parent_Id.Account_Name from Client_Review where id is not null group by Parent_Id.Account_Name " } |
Response : In case you missed out our newsletter and announcement and could not fill out the feedback form, it is not too late to do it now. We invite you to take a few minutes, fill out the feedback
form and share your queries and thoughts. We will continue to reply to your questions in our upcoming Kaizen posts.
Cheers!