Kaizen 169 - Serialization and Schema Management in Queries

Kaizen 169 - Serialization and Schema Management in Queries


Hello everyone!

Welcome back to another post in the Kaizen series!

In Kaizen #166, we discussed handling Variables in Queries and associating the query in Kiosk.
This week, we will discuss Serialization and Schema management in Queries.

Business Scenario

Let's consider the same use case of Delivery Hub discussed in Kaizen #166.

Here, a tele-commerce platform uses Zoho CRM to manage sales and deliveries. When a customer provides their PIN code, the salesperson must confirm with the customer for a nearby post office for package pick-ups and drop-offs in Kiosk.

For this case, we wrote a query with the Source as REST API. When a PIN code was entered, the query dynamically retrieved the list of post offices in that area and displayed it on the Contact's detail page.

Let's take it a step further and see how we can serialize the response.
When you query by entering a PIN code, the response contains all post offices in that area including the ones that are non-operational.

To display only relevant data and leverage the capabilities of the Queries feature, you can serialize the response to display only those post offices that are operational(with the value "DeliveryStatus":"Delivery") along with the names of those post offices.

We will also see how Schema varies based on serialization.

Serialization

Serialization refers to the process of transforming complex data structures into a format that is more meaningful and relevant to your business needs. In Zoho CRM Queries, serialization affects how responses are formatted and what data is included.

Serialization offers the following:
  • Response Customization: By serialization, you can manipulate the output of a query to focus on relevant fields. For example, if a query retrieves multiple post offices, serialization can filter these results to display only those marked as 'deliverable'.
  • Schema Adjustment: When you serialize the response, the schema changes. This allows you to have only relevant data in the serialized output like the required fields, especially while querying a module with multiple relationships.
  • User Experience: Serialization avoids unnecessary information clutter, giving the users only what they need, thereby improving their overall experience.

Example

Consider the example of Delivery Hub. For PIN 110042, the response contains a list of six post offices in that area.

{ Name: 'Badli (North West Delhi)' , Description: null , BranchType: 'Sub Post Office' , DeliveryStatus: 'Non-Delivery' , Circle: 'Delhi' , District: 'North West Delhi' , Division: 'Delhi North' , Region: 'Delhi' , Block: 'Delhi' , State: 'Delhi' , Country: 'India' , Pincode: '110042' }
1
:
{ Name: 'Delhi Engg. College' , Description: null , BranchType: 'Sub Post Office' , DeliveryStatus: 'Non-Delivery' , Circle: 'Delhi' , District: 'North West Delhi' , Division: 'Delhi North' , Region: 'Delhi' , Block: 'Delhi' , State: 'Delhi' , Country: 'India' , Pincode: '110042' }

{ Name: 'Pehlad Pur' , Description: null , BranchType: 'Branch Post Office' , DeliveryStatus: 'Delivery' , Circle: 'Delhi' , District: 'North West Delhi' , Division: 'Delhi North' , Region: 'Delhi' , Block: 'Delhi' , State: 'Delhi' , Country: 'India' , Pincode: '110042' }
3
:
{ Name: 'Samai Pur' , Description: null , BranchType: 'Sub Post Office' , DeliveryStatus: 'Delivery' , Circle: 'Delhi' , District: 'North West Delhi' , Division: 'Delhi North' , Region: 'Delhi' , Block: 'Delhi' , State: 'Delhi' , Country: 'India' , Pincode: '110042' }
4
:
{ Name: 'Shahbad Daulatpur' , Description: null , BranchType: 'Branch Post Office' , DeliveryStatus: 'Delivery' , Circle: 'Delhi' , District: 'North West Delhi' , Division: 'Delhi North' , Region: 'Delhi' , Block: 'Delhi' , State: 'Delhi' , Country: 'India' , Pincode: '110042' }
5
:
{ Name: 'Siraspur' , Description: null , BranchType: 'Branch Post Office' , DeliveryStatus: 'Delivery' , Circle: 'Delhi' , District: 'North West Delhi' , Division: 'Delhi North' , Region: 'Delhi' , Block: 'Delhi' , State: 'Delhi' , Country: 'India' , Pincode: '110042' }

Now, we will use serialization to display only those post offices that deliver with the value DeliveryStatus = 'Delivery' .
You can serialize the response using JavaScript. Here is the code.

const postOffices = result[0]?.PostOffice;

// Ensure `postOffices` is iterable
const postOfficesArray = Array.isArray(postOffices)
? postOffices
: (postOffices ? Object.values(postOffices) : []);

const filteredResults = [];

// Filter and manually extract `Name` and `DeliveryStatus`
for (const office of postOfficesArray) {
if (office.DeliveryStatus === "Delivery") {
filteredResults.push({ Name: office.Name, DeliveryStatus: office.DeliveryStatus });
}
}

return filteredResults;

Let's see how serialization brings a difference in the output.

Output when fetching all post offices


Serialized output displaying only the name and status of the post offices that deliver

As you can see, serialization makes the output less bloated and a lot more meaningful and relevant.

Schema Management

For every query, the schema is auto-generated. It outlines the structure of the retrieved data and helps identify the path of each field, its CRM field type, and the label.
You can modify the auto-generated schema to suit your requirements better. You can update field labels and types, which helps in presenting data in a more user-friendly way.
For example, if a query returns a field labeled "Deal Stage," you can rename it to "Current Status" for clarity when displaying results on dashboards or reports.
Let's look at the schema when fetching all post offices for a PIN code vs the schema of the serialized response.

Schema before serialization


Schema after serialization


You can see that serializing helps you achieve crisper results.
It shows the CRM field type of every field in the response and its label. You can further customize the schema by changing the field labels to suit your needs.
In the following image, the field label for DeliveryStatus is changed to Status in the serializer which is reflected in the schema.


We hope you found this post useful. Watch this space for more posts on interesting topics.

We love to hear from you! Write to us at support@zohocrm.com.
See you all next week!

Cheers!




-------------------------------------------------------------------------------------------------------------



    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • Kaizen #197: Frequently Asked Questions on GraphQL APIs

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Kaizen #198: Using Client Script for Custom Validation in Blueprint

                                                              Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

                                                              Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
                                                            • Kaizen #193: Creating different fields in Zoho CRM through API

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Client Script | Update - Introducing Commands in Client Script!

                                                              Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands


                                                            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


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Image Upload Field | Zoho Canvas

                                                                                                              I'm working on making a custom view for one of our team's modules. It's an image upload field (Placement Photo) that would allow our sales reps to upload a picture of the house their working on. However, I don't see that field as a opinion when building
                                                                                                            • Function #9: Copy attachments of Sales Order to Purchase Order on conversion

                                                                                                              This week, we have written a custom function that automatically copies the attachments uploaded for a sales order to the corresponding purchase order after you convert it. Here's how to configure it in your Zoho Books organization. Custom Function: Hit
                                                                                                            • RingCentral/Zoho CRM integration

                                                                                                              Hi I would like to know if our RingCentral/Zoho CRM integration will record incoming calls from clients to my mobile number. I have both Ringcenral and Zoho CRM apps on my iPhone. I know it records the outgoing calls I make and shows them in Zoho CRM
                                                                                                            • Zoho CRM button to download images from image upload field

                                                                                                              Hello, I am trying to create a button in Zoho CRM that I can place in my record details view for each record and use it to download all images in the image upload fields. I tried deluge, client scripts and even with a widget, but feel lost, could not
                                                                                                            • Free webinar: Security that works: Building resilience for the AI-powered workforce

                                                                                                              Hello there, Did you know that more than 51% of organizations worldwide have experienced one or more security breaches, each costing over $1 million in losses or incident response? In today’s threat landscape, simply playing defense is no longer enough.
                                                                                                            • Range names in Zoho Sheet are BROKEN!

                                                                                                              Hi - you've pushed an update that has broken range names. A previously working spreadsheet now returns errors because the range names are not updating the values correctly. I've shared a video with the support desk to illustrate the problem. This spreadsheet
                                                                                                            • The connected workflow is a great idea just needs Projects Integrations

                                                                                                              I just discovered the connected workflows in CRM and its a Great Idea i wish it was integrated with Zoho Projects I will explain our use case I am already trying to do something like connected workflow with zoho flow Our requirement was to Create a Task
                                                                                                            • Cliq iOS can't see shared screen

                                                                                                              Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
                                                                                                            • Enhancements in Portal User Group creation flow

                                                                                                              Hello everyone, Before introducing new Portal features, here are some changes to the UI of Portals page to improve the user experience. Some tabs and options have been repositioned so that users can better access the functionalities of the feature. From
                                                                                                            • Archiving Contacts

                                                                                                              How do I archive a list of contacts, or individual contacts?
                                                                                                            • Cant Save Gauge on Creator Page

                                                                                                              How to Save Gauge on Creator Page see movie https://vimeo.com/1116410860?share=copy#t=0
                                                                                                            • Update application by uploading an updated DS file

                                                                                                              Is it possible? I have been working with AI on my desktop improving my application, and I have to keep copy pasting stuff... Would it be possible to import the DS file on top of an existing application to update the app accordingly?
                                                                                                            • Granular Email Forwarding Controls in Zoho Mail (Admin Console and Zoho One)

                                                                                                              Hello Zoho Mail Team, How are you? At present, the Zoho Mail Admin Console allows administrators to configure email forwarding for an entire mailbox, forwarding all incoming emails to another address. This is helpful for delegation or backup purposes,
                                                                                                            • Change Currency symbol

                                                                                                              I would like to change the way our currency displays when printed on quotes, invoices and purchase orders. Currently, we have Australian Dollars AUD as our Home Currency. The only two symbol choices available for this currency are "AU $" or "AUD". I would
                                                                                                            • Auto Capitalize First Letter of Words

                                                                                                              Hi I am completely new to ZOHO and am trying to build a database. How can i make it when a address is entered into a form field like this: main st it automatically changes is to show: Main St Thank You
                                                                                                            • Follow-up emails via Workflow Automation not staying in the same thread

                                                                                                              Dear Zoho Support Team, I am currently using Workflow Automation in Zoho Campaigns to send follow-up emails. In my test case, I noticed the following behavior: All emails in the automation have the same subject line. If the follow-up email is sent within
                                                                                                            • Client Script refuses to set an initial value in Subform field

                                                                                                              I tried a very simple, 1 line client script to set a default value in a custom subform field when the "Add Row" button is clicked and the user is entering data. It does not work - can someone tell me why? ZDK documentation suggests this should be doable.
                                                                                                            • How do I filter contacts by account parameters?

                                                                                                              Need to filter a contact view according to account parameter, eg account type. Without this filter users are overwhelmed with irrelevant contacts. Workaround is to create a custom 'Contact Type' field but this unbearable duplicity as the information already
                                                                                                            • Send / Send & Close keyboard shortcuts

                                                                                                              Hello! My team is so close to using Zoho Desk with just the keyboard. Keyboard shortcuts really help us to be more efficient -- saving a second or two over thousands of tickets adds up quickly. It seems like the keyboard shortcuts in Desk are only for
                                                                                                            • Zoho Social - Post Footer Templates

                                                                                                              As a content creator I often want to include some information at the end of most posts. It would be great if there was an option to add pre-written footers, similar to the Hashtag Groups at the end of posts. For example, if there is an offer I'm running
                                                                                                            • Zoho Expense - The ability to add detail to a Trip during booking

                                                                                                              As an admin, I would like the ability to add more detail to the approved Trips. At present a requestor can add flights, accommodation details and suggest their preferences. It would be great if the exact details of the trip could be added either by the
                                                                                                            • Simplified Call Logging

                                                                                                              Our organization would like to start logging calls in our CRM; however, with 13 fields that can't be removed, our team is finding it extremely cumbersome. For our use case, we only need to record that a call happened theirfor would only need the following
                                                                                                            • Week date range in pivot table

                                                                                                              Hello, I need to create a report that breakouts the data by week.  I am using the pivot table report, and breaking out the date by week, however the date is displayed as 'Week 1 2014' format.  Is there anyway to get the actual dates in there? ex. 1/6/2014-1/12/2014 Thanks,
                                                                                                            • Help Center IFrame Issue

                                                                                                              I have had a working Help Center on my website using an iframe for a while. But now for some reason the sign in page gets a refused to connect error. Can someone please help. If I go to the url manually it works correclty
                                                                                                            • Staff rules

                                                                                                              Hi! Do you people know what are the default staff rules when a new booking is created? We have two staff members in my team (me as the admin, and my employee). As we share the same services, I'm wondering how Zoho will pick the staff for new apointments.
                                                                                                            • Comment Templates

                                                                                                              Is it possible to add a template option for comments? We have some agents in the process who's responses require a pre-formatted layout. It would be incredibly handy to have a template for them where they can insert the template and then add their responses
                                                                                                            • [ZohoDesk] Improve Status View with a new editeble kanban view

                                                                                                              A kanban view with more information about the ticket and the contact who created the ticket would be valueble. I would like to edit the fields with the ones i like to see at one glance. Like in CRM where you can edit the canvas view, i would like to edit
                                                                                                            • Adding Markdown text using Zoho Desk API into the Knowledge Base

                                                                                                              Hi Zoho Community members, We currently maintain the documentation of out company in its website. This documentation is written in markdown text format and we would like to add it in Zoho Knowledge Base. Do you know if there is REST API functionality
                                                                                                            • An Exclusive Session for Zoho Desk Users: AI in Zoho Desk

                                                                                                              A Zoho Community Learning Initiative Hello everyone! This is an announcement for Zoho Desk users and anyone exploring Zoho Desk. With every nook and corner buzzing, "AI's here, AI's there," it's the right time for us to take a closer look at how the AI
                                                                                                            • Shared values: From classroom lessons to teaching moments in customer service

                                                                                                              While the world observes Teachers’ Day on October 5, in India, we celebrate a month earlier, on September 5, to mark the birth anniversary of Dr. Sarvepalli Radhakrishnan, a great teacher, renowned scholar, educationist, and advocate for empowerment.
                                                                                                            • Export to excel stored amounts as text instead of numbers or accounting

                                                                                                              Good Afternoon, We have a quarterly billing report that we generate from our Requests. It exports to excel. However if we need to add a formula (something as simple as a sum of the column), it doesn't read the dollar amounts because the export stores
                                                                                                            • Create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM

                                                                                                              How to create a list of customers who participated in specific Zoho Backstage events and send them an email via Zoho CRM? I was able to do a view in CRM based on customer that registered to an event, but I don't seems to be able to include the filter
                                                                                                            • Custom Button Disappearing in mobile view | Zoho CRM Canvas

                                                                                                              I'm working in Zoho CRM Canvas to create a custom view for our sales team. One of the features I'm adding is a custom button that opens the leads address in another tab. I've had no issue with this in the desktop view, but in the mobile view the button
                                                                                                            • Zoho Desk blank page

                                                                                                              1. Click Access zoho desk on https://www.zoho.com/desk/ 2. It redirects to https://desk.zoho.com/agent?action=CreatePortal and the page is blank. Edge browser Version 131.0.2903.112 (Official build) (arm64) on MacOS
                                                                                                            • Clearing Fields using MACROS?

                                                                                                              How would I go about clearing a follow-up field date from my deals? Currently I cannot set the new value as an empty box.
                                                                                                            • I hate the new user UI with the bar on the left

                                                                                                              How can I reverse this?
                                                                                                            • Constant color of a legend value

                                                                                                              It would be nice if we can set a constant color/pattern to a value when creating a chart. We would often use the same value in different graph options and I always have to copy the color that we've set to a certain value from a previous graph to make
                                                                                                            • Office 365 and CRM mail integration: permission required

                                                                                                              Has anyone run into this weird problem? My email server is Office 365. When I try to configure Zoho CRM to use this server, a Microsoft popup window opens requesting user and password. After entering that, I get a message in the Microsoft window saying
                                                                                                            • Field Not Updating in FSM Script - Service and Parts module.

                                                                                                              Dear Team, I am reaching out regarding a script I have implemented in Zoho FSM to automate the calculation of the End of Service date based on the End of Sale date in the Service and Parts module. Overview of the script: Fetches the End_of_Sale__C and
                                                                                                            • Question regarding import of previous deals...

                                                                                                              Good afternoon, I'm working on importing some older deal records from an external sheet into the CRM; however, when I manually click "Add New Deal" and enter the pertinent information, the deal isn't appearing when I look at the "Deals" bar on the account's
                                                                                                            • Next Page