Kaizen #206 - Answering your Questions | Displaying Related Purchase Orders from Zoho Books in CRM Deals using Queries

Kaizen #206 - Answering your Questions | Displaying Related Purchase Orders from Zoho Books in CRM Deals using Queries


Hello everyone!
We're back with another post in the Kaizen series.
We're grateful for the feedback we received from all of you!

One of the questions we received was "I would like to see the list of Purchase Orders in Zoho Books for a Deal in CRM."

We will discuss how to achieve this using the Queries feature in Zoho CRM.

Scenario

In many organizations, a single Deal in Zoho CRM may correspond to one or more Purchase Orders(POs) in Zoho Books. To get a real-time view of all POs associated with a Deal in CRM, we can leverage the Queries feature under Setup > Developer Hub > Queries, and custom related lists.

1. CRM and Zoho Books Integration

Zoho CRM and Books integration allows you to
  • View POs, invoices, and payments for deals directly in CRM
  • Synchronize financial data between CRM deals and Books POs
  • Automate the mapping of deals to POs via custom fields
To create this connection,
  1. Go to Setup > Developer Hub > Connections
  2. Create a connection to Books(OAuth) with the scopes ZohoBooks.contacts.All and ZohoBooks.purchaseorders.All.

2. Prerequisites

Before creating the query and automation, you must have the following ready:
  1. Zoho Books organization ID – needed for REST API calls.
  2. Custom field in Books PO module:
    Field Name: CRM Deal ID
    Type: Single-line
    Purpose: Store the CRM deal ID that each PO relates to.
    Why do we need this custom field?
    By default, Books POs are not directly linked to CRM Deals. To bridge this gap, we create a custom single-line field(CRM Deal ID) in Books POs to store the CRM Deal’s record ID. This makes it possible to filter POs in queries(cf_crm_deal_id == {{deal_ID}}) and reliably display only the related POs in CRM.

    You can store the record ID of the deal in CRM in this field either manually or via a custom function. When you use a custom function, use the Update a Purchase Order API to update the CRM Deal ID field in Books with the record ID of the deal in CRM. You can then associate this function to a button or automation to constantly update the PO in Books every time a deal in CRM is created or updated in CRM. You can also use Zoho Flow to achieve this instead of a function.
  3. Trusted domain and source:
    1. Ensure you have added Books API domain to trusted domain for API calls.

    2. Add Zoho Books as the source of the query to get the PO details from Books. You can add the Books' organization ID as a parameter either here or while creating the query.

3. Single Deal, Multiple POs

Scenario

  • A CRM deal requires multiple POs from different vendors.
  • Each PO in Books stores the same Deal ID in the CRM Deal ID field.
  • This allows a related list in CRM to show all POs associated with the deal.

Why a Single-line Field Works?

  • Each PO references one deal.
  • Queries in CRM can filter using cf_crm_deal_id == {{deal_ID}}. cf_crm_deal_id is the API name of the custom field in PO of Books. You can find it under Setup > Purchases > Purchase Orders > {the custom field} > Edit.
  • Works reliably for related list display.

4. Creating a REST API Query in CRM

Since we will use Books API to get the list of POs, we will create a REST API type query.

  1. Go to Setup > Developer Hub > Queries > Create Query.
  2. Enter the details as shown in the following image:

  3. Choose the Books source that you added recently.
  4. Give a name for the query.
  5. The API name will be auto-populated, and the URL will be populated from the source.
  6. Enter the endpoint to access the resource from Books. In our case, purchaseorders.
  7. To filter based on the value in the CRM Deal ID field in Books, enter the parameter as cf_crm_deal_id and its value as a variable. This variable takes the Deal's record ID as the value during run time. This ensures that the query takes the deal residing in the CRM Deal ID(which is also the record ID of the deal in CRM) field in Books and filters only those POs related to this Deal.
  8. If you have not given org_id as a parameter while creating the source, include it here.
  9. Click Next. You will get a pop-up asking for the value to the variable cf_crm_deal_id. Give a value to see the query in action.
  10. The query returns the list of POs from Books that are related to this particular deal in CRM.
  11. Save the query.

5. Serializing(to return a table for the related list)

Serializer allows you to manipulate the response of the query using Javascript.
In our example, the raw response of the query will contain the POs from Books for a deal in CRM as an array with many fields.
For example, the deal with CRM record ID 3652397000017912047 has two POs in Books viz, PO-00001 and PO-00003. The raw response before serialization is as follows.


But, to associate this response with a related list, we don't need all the fields. We can use the serializer to modify this response and use only the required fields.
The following image shows the serialized response.


Click Save and configure the Schema.


Click Save to save the query.

6. Adding the Query to a Related List

Now that we have the query ready, let's associate this with a related list in the Deals module in CRM to contextually view the POs of the Deal in Books.
  1. Navigate to the Deals module in CRM.
  2. Click the three-dot icon on the right corner of the record, and click Add Related List. Alternatively, you can also click the Add Related List option on the left in the Related List pane.

  3. From the pop-up, select Queries.

  4. From the list of available queries, select the Get Purchase Orders query you created and click Associate.

  5. Give a name for the related list.
  6. Under Variable Mapping, type #(to view merge fields) to get the list of modules available. Choose Deals and the Deal Id field. This means that the record ID of the deal will be passed as the value of the cf_crm_deal_id variable at runtime. The query will then fetch the list of POs for this Deal ID from Books, and display it in this related list.

  7. Click Save and you will see the related list under the Related Lists section of the record.

  8. Reload the page to see the query in action.

Automation Options

You can automatically update the CRM Deal ID in Books POs when a deal is created or a PO is raised.

1. Using Function

  • Function triggers on deal creation or a button click in CRM.
  • Fetches the PO in Books and updates the CRM Deal ID field using the Books connection.

2. Using Zoho Flow

  • Event: Deal created or updated in CRM.
  • Action: Update the corresponding PO(s) in Books.
  • Works without writing Deluge code.
Both methods require the Books connection and organization ID.

Summary/Best Practices

  • Single Deal, Multiple POs: Use single-line CRM Deal ID field in Books.
  • Queries and serializer: Filter POs based on cf_crm_deal_id == {{deal_ID}}.
  • Automation: Use functions or Zoho Flow for real-time updates.
  • Multi-Deal, Single PO: Not supported for related lists; use custom reporting instead.

This setup ensures that sales and finance teams can see all POs for a deal directly in CRM without manual reconciliation.


We hope this post answered your question and you found this useful.
Let us know what you think in the comments or write to us at support@zohocrm.com.


Cheers!


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










    Access your files securely from anywhere









                          Zoho Developer Community




                                                • Desk Community Learning Series


                                                • Digest


                                                • Functions


                                                • Meetups


                                                • Kbase


                                                • Resources


                                                • Glossary


                                                • Desk Marketplace


                                                • MVP Corner


                                                • Word of the Day


                                                • Ask the Experts





                                                          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

                                                                                            Get Started. Write Away!

                                                                                            Writer is a powerful online word processor, designed for collaborative work.

                                                                                              Zoho CRM コンテンツ






                                                                                                Nederlandse Hulpbronnen


                                                                                                    ご検討中の方




                                                                                                          • Recent Topics

                                                                                                          • Send Automated WhatsApp Messages and Leverage the Improved WhatsApp Templates

                                                                                                            Greetings, I hope all of you are doing well. We're excited to announce a major upgrade to Bigin's WhatsApp integration that brings more flexibility, interactivity, and automation to your customer messaging. WhatsApp message automation You can now use
                                                                                                          • Script Editor not an option

                                                                                                            I am trying to apply a script to a sheet and Script Editor is not an option. I don't want to go outside Sheets to do this (like Creator) if it can be done inside Sheets.
                                                                                                          • Envio de mails

                                                                                                            Hola! No puedo enviar mails pero si recibirlos. No se como solucionarlo! Mi dominio es chidobebes.com.ar
                                                                                                          • ERROR CODE :554 - Your access to this mail system has been rejected due to poor reputation of a domain used in message transfer

                                                                                                            In my email configuration: The domain's MX Records are pointed to Zoho The domain's SPF Records have been pointed out successfully DKIM is enabled. DMARC Record is pointed for the domain. The domain name is digioorja.in. Still facing the issue of Error:
                                                                                                          • This Operation has been restricted. Please contact support-as@zohocorp.com for further details

                                                                                                            l tried to verify my domain (casalimpaeperfumada.com.br) and its shows this error: This Operation has been restricted. Please contact support-as@zohocorp.com for further details.
                                                                                                          • SLOW EMAILS

                                                                                                            Is there an issue with the Zoho server? For two days now I've been having issues with very long buffering. Please advise. Thank you.
                                                                                                          • POP3 authentication error - SOLVED

                                                                                                            Just in case others are as forgetful as me ... As Zoho has changed the POP server for personal and free organisational users, I needed to change the POP server on my email client. This failed persistently but eventually I remembered that I had chosen
                                                                                                          • Solution to Import PST File into Office 365.

                                                                                                            MailsDaddy OST to Office 365 Migration Tool is an outstanding solution to recover OST files and migrate them into Office 365 without any hassle. Using this software users can multiple OST files into Office 365 with complete data security. It offers users
                                                                                                          • Add Zoho One Groups/Departments to Shared Mailbox Access

                                                                                                            Hi, I hope you're doing well. Currently, in Zoho Mail, I can manually add specific users or the entire organization to a shared mailbox. However, there is no option to add Zoho One groups or departments. Feature Request: We would like the ability to assign
                                                                                                          • Allow Filters with Only Special Characters in Zoho Mail

                                                                                                            Hi Zoho Mail Team, I hope you're doing well. We have noticed that currently, Zoho Mail does not allow creating filter criteria using only special characters, such as = or #. However, there are scenarios where such a filter is necessary. For example: Filtering
                                                                                                          • How to save email as PDF?

                                                                                                            I saw 2 previous threads about this. One is from 14 years ago. The other was closed as "answered" a year ago but the feature was never implemented: https://help.zoho.com/portal/en/community/topic/how-to-download-save-emails-as-pdf Is the "save as PDF"
                                                                                                          • Flexible plans

                                                                                                            Hi, I have a Workplace Standard subscription. On Zoho's website, it mentions that with the annual plan it's possible to have multiple plans under the same organization—for example, Workplace Standard and Mail Lite. However, I can’t find a way to do this
                                                                                                          • Weekly Tips : Teamwork made easy with Multiple Assignees

                                                                                                            Let's say you are working on a big project where different parts of a single task need attention from several people at the same time—like reviewing a proposal that requires input from sales, legal, and finance teams. Instead of sending separate reminders
                                                                                                          • Cannot give public access to Html Snippet in Zoho Creator Page

                                                                                                            Hi, I created a form in Zoho Creator and published it. The permalink works but I want to override the css of the form. (style based URL parameters is not good enough) So I created a page and added an Html snippet. I can now override the css, which is
                                                                                                          • Weekly Tips : Customize your Compose for a smoother workflow

                                                                                                            You are someone who sends a lot of emails, but half the sections in the composer just get in your way — like fields you never use or sections that clutter the space. You find yourself always hunting for the same few formatting tools, and the layout just
                                                                                                          • Unable to confirm Super Admin assignment — confirmation button not working

                                                                                                            I’m trying to change the roles within my organization. I am currently a super admin and would like to add another user as a super admin. When I attempt to confirm the action, a screen appears asking for my password to verify my identity. However, when
                                                                                                          • Installing EMAIL Setup in New Domain

                                                                                                            Respected Support team, I'm facing an issue with cloudflare in Pakistan, I want to setup Zoho Mail Setup but I Don't know how to enable Zoho mail setup without cloudflare. My Website https://stumbleguyzzapk.com/, https://fakservices.com/ is using CF,
                                                                                                          • Will I Get a Refund If I Downgrade Zoho Mail?

                                                                                                            Hello, We upgraded an email account for our new employee. However, the employee left after one month, and now I've reduced the number of Zoho Mail users from 7 to 6. Can we get a refund for the remaining portion of our annual payment?
                                                                                                          • Accounting on the Go Series-43:Enhancing Your Reporting Efficiency with Dashboard Filter State Retention

                                                                                                            Hello everyone! Welcome back to our series on Zoho Books mobile app features. Today, we will talk about a feature that yet again helps you focus on work that really matters-Dashboard Filter State Retention. Imagine you're working on your Zoho Books dashboard,
                                                                                                          • Zoho books/payroll tax payment

                                                                                                            I accidentally made a second payment to my taxes for $300 which is reflected in my bank account and therefore on Zoho books but I can not match it to any transactions because its not reflected in payroll as a tax payment. Is there a way to add an extra
                                                                                                          • I can't renew the Finance Plus subscription

                                                                                                            I tried to renew the Finance Plus subscription but it keeps reloading the same page over and over when ever I click on "Renew Subscription" button
                                                                                                          • Estimate vs Quote

                                                                                                            they are different. Quote is for 1 piece price + other charges. Estimate is for total quantity to be ordered. The gross total amount of the Estimate is the amount payable. Replacing Estimate as Quote is not understandable because they are different. In
                                                                                                          • Accounting on the Go Series-47: Effortless GSTIN Management- Auto Populate TaxPayer Details in Zoho Books Mobile App

                                                                                                            Hello everyone, Welcome back! Today, we're focusing on a feature specifically designed for our Indian users in the Zoho Books-Indian edition, particularly those who deal with GST compliance regularly. We understand the importance of accurate and efficient
                                                                                                          • Accounting on the Go Series-48: Enhance Accuracy with Custom Work Week Start Days in Zoho Books iOS app

                                                                                                            Hello everyone, Welcome back! We’re here with another feature spotlight that might seem small but can have a big impact on your daily routine: setting the first day of the work week in the Zoho Books iOS app. Imagine this: You’re a business owner who
                                                                                                          • Time to Get Paid Report in ZBooks

                                                                                                            Hello, One of our customers who has 25 different companies around the world gets 60 days to make payments. Unfortunately, the subject report does not report an average time to get paid (in days) or the ability to look at a custom period of time. Currently
                                                                                                          • How to prepare a balance sheet for a company that has no operations yet?

                                                                                                            .
                                                                                                          • Project Billing Method from Zoho People

                                                                                                            Normaly our customers use Zoho Projects to manage projects and timesheet that are being charge to the customer. Using the integration from Zoho Project we can have projects base on different billing method. For example most of our customer use Hourly
                                                                                                          • Bug tracking

                                                                                                            Hi, does anyone know how to track errors during picking or packing? This way I can keep track and see how to improve and prevent errors in this area.
                                                                                                          • Zoho Books-Accounting on the Go Series!

                                                                                                            Dear users, Continuing in the spirit of our 'Function Fridays' series, where we've been sharing custom function scripts to automate your back office operations, we're thrilled to introduce our latest initiative – the 'Zoho Books-Accounting on the Go Series'.
                                                                                                          • Zoho Books | Product updates | July 2025

                                                                                                            Hello users, We’ve rolled out new features and enhancements in Zoho Books. From plan-based trials to the option to mark PDF templates as inactive, explore the updates designed to enhance your bookkeeping experience. Introducing Plan Based Trials in Zoho
                                                                                                          • Zoho Books | Product updates | August 2025

                                                                                                            Hello users, We’ve rolled out new features and enhancements in Zoho Books. From the right sidebar where you can manage all your widgets, to integrating Zoho Payments feeds in Zoho Books, explore the updates designed to enhance your bookkeeping experience.
                                                                                                          • Apply Payment Received Amount Zoho Books Invoice

                                                                                                            Hello team here is the sample code How can apply the payment received record over a unpaid zoho books invoice. //......................... paymentID = customer_payment.get("payment_id"); organizationID = organization.get("organization_id"); paymentmaplist
                                                                                                          • Update or Upsert Records Using Unique Custom Fields

                                                                                                            Hello customers, We've enhanced the process of updating records via API. You can now: Update records using unique custom fields Upsert records using unique custom fields Note: Both the features are available in the Zoho Books and Zoho Inventory apps.
                                                                                                          • [Webinar] Understanding the New Invoice Management Systems

                                                                                                            Join industry expert CA Pritam Mahure as he discusses the importance of the new Invoice Management System (IMS) and its impact on taxpayers. Topics Covered: - Concept of IMS and pre-requisites - Applicability and Restrictions on Invoices/Records for IMS
                                                                                                          • Accounting on the Go Series-51: Effortless Transactions: Create and Manage Directly from Uploaded Documents

                                                                                                            Hello everyone, We’re back with another useful feature that makes working with Zoho Books even easier! This time, we’re simplifying the process of creating transactions directly from uploaded documents. Imagine you’re out meeting clients, and you receive
                                                                                                          • [WEBINAR] Effortless migration to the VAT-ready South Africa edition of Zoho Books

                                                                                                            Hello there, If you are one of our early users from South Africa using the older edition of Zoho Books, this webinar is for you! We have now launched a new South Africa edition with VAT support, to which you can migrate your existing data. Join this session,
                                                                                                          • Accounting on the Go Series-52: Capture Receipts on the Go, Right from Your Lock Screen.

                                                                                                            Hello everyone, We’re excited to introduce a feature that will make your life so much easier—especially for those constantly on the move! With iOS 18, Zoho Books now allows you to capture receipts directly from your lock screen using Locked Camera Capture.
                                                                                                          • 2024 Email Authentication Standards: Elevating Security with Google and Yahoo

                                                                                                            In contemporary email communication, email authentication plays a pivotal role in mitigating email fraud, spam, and phishing attacks. Brace yourself for a new level of security. Starting February 2024, Gmail and Yahoo will be implementing robust email
                                                                                                          • AT - Austrian Accountant familiar with ZOHO

                                                                                                            Hello, as I have just migrated to ZOHO and unfortunately have to change my accountant next year, I am looking for an accountant (for Austria) who already has experience with Zoho or who already manages clients using Zoho books. Is there anyone here from
                                                                                                          • Zoho Workflow issue

                                                                                                            Dear Zoho Users, I have Zoho Books premium subscription, I have created a email alerts workflow for Invoices and following are the configurations for the same: 1. Workflow for Invoice module 2. Choose when to tigger - created or edited 3. Filter the triggers
                                                                                                          • Next Page