Hello Everyone,
Welcome back to an exceptional edition of the Kaizen series!
Today marks Kaizen #250, an exciting milestone in our journey of exploring, learning, and building with Zoho CRM. Over the past 249 editions, we've covered a wide range of features, APIs, best practices, and real-world use cases designed to help you get more out of Zoho CRM. A heartfelt thanks to everyone who has followed the series, shared feedback, asked thoughtful questions, and supported this journey along the way.
Until now, we've primarily used Queries as a read-only capability allowing us to fetch data, transform it using a Serializer, and display it in components such as Canvas and Kiosk. However, whenever we had to update a CRM record, such as setting a lookup field or modifying a value we had to rely on Custom Functions or Client Scripts.
What's new
Query Workbench's REST API source type supports GET, POST, PUT, PATCH, and DELETE, which means a Query can now perform the write itself, end-to-end.
Why this matters
The latest enhancement to the Queries feature enables you to automate dynamic lookup assignments directly within Zoho CRM. In this post, we'll use a practical example to show how this enhancement works in a Blueprint-driven Kiosk flow.
Business scenario
Zylker Field Services manages a team of Field Engineers across multiple service zones. Whenever a new Service Application is created, a dispatcher is responsible for manually identifying the most suitable engineer by matching the application's Zone and Specialization, and selecting the engineer with the lowest Active_Request_Count before assigning the request.
The Operational Problem
Traditionally, this process is manual:
- The dispatcher opens the Field Engineers module.
- Filters engineers by the required Zone and Specialization.
- Compares each engineer's Active_Request_Count.
- Assigns the engineer with the lightest workload.
This approach is both time-consuming and difficult to scale. As the number of service requests and engineers grows, manually comparing workloads becomes inefficient and can lead to uneven distribution of work.
Solution Overview
To automate engineer assignment, we'll build a Kiosk that is triggered from the Assign Engineer Blueprint transition. The Kiosk uses GetRecords state to retrieve the most suitable engineer and update the required records directly through the Queries with Zoho CRM REST API source.
The solution works as follows:
- The Kiosk is launched when the Service Application enters the Assign Engineer Blueprint transition.
- The GetRecords state fetches the Field Engineers module for engineers who match the Service Application's Zone and Specialization, filters only active engineers, and sorts the results by Active_Request_Count in ascending order.
- If a matching engineer is found, the Kiosk, updates the Field_Engineer lookup field on the Service Application by invoking the Query.
Finally, the Kiosk displays a confirmation message and completes the Blueprint transition.
If no suitable engineer is found, the Kiosk notifies the dispatcher, preventing the transition from completing until the assignment can be handled manually.
This approach ensures that every Service Application is assigned to the best-fit, least-loaded engineer while keeping the implementation entirely within native CRM components.
Implementation
Step 1: Create a Query to Update the Field Engineer Lookup in Service Application Module
- Navigate to Setup -> Developer Hub -> Queries.
- Click Create Query, provide a name, and click Next.
- In the Query Workbench, select Zoho CRM REST API as the Source.
- Set the Request Method to PUT.
Specify the relative path for the Update Records API, passing the Service Application record ID as a variable. /v8/Service_Applications/{{service_record_id}} |
- Select Raw as the Body Type.
Enter the following request body. The Kiosk dynamically populates the lookup field values.
{ "data": [ { "id": "{{service_record_id}}", "Field_Engineer": { "id": "{{engineer_id}}", "name":"{{engineer_name}}" } } ] } |
Provide the code to the Serializer to format the response according to your requirements. If the result contains data it will return "Field Engineer Assigned".
const apiResult = result?.data?.[0] ?? {};
return [{ Message: "Field Engineer Assigned" ?? "Engineer Lookup Field Update Failed" }]; |
- Click Execute Query to verify the request and Save the Query.
Step 2: Create a Kiosk to Retrieve and Assign the Field Engineer
Create a Kiosk that retrieves the most suitable engineer and updates the Field_Engineer lookup field during the Blueprint transition.
- Navigate to Setup -> Customization -> Kiosk Studio
- Click Create Kiosk
- Provide a name and click Next
- Select Service Applications as the current module.
Add a Get Records state
- Add a Get Records state and name it Get Suitable Field Engineer.
- Associate the Query that retrieves Field Engineers based on:
- Zone
- Specialization
- Active status
- Sort the results by Active_Request_Count in ascending order so that the least-loaded engineer is returned.
Add a Decision state
- Add a Decision state after the Get Records state.
- Name the decision Engineer Found.
- Configure the condition to check whether the Query returned a matching engineer.
- Create two paths:
- Assign Engineer
- Default