Function #25: Automatically generate purchase orders from a sales order

Function #25: Automatically generate purchase orders from a sales order

We kicked off the "Function Fridays" series with the goal of helping you automate your everyday accounting tasks. As we delve into today's post, I'm delighted to announce that we're here to present the 25th custom function in this series. While it is a small milestone, we are committed to continuing this series to provide more functions that can save you time and significantly enhance the efficiency of your business operations. You can find a complete list of all the functions we've shared to date by visiting this link. 

Coming to today's function, you're likely familiar with the feature in Zoho Books that allows you to raise multiple purchase orders from a sales order when item quantities are running low or depleted. If your sales order has several low-stock items that must be procured from different vendors, manually creating separate purchase orders for each vendor can become quite a time-consuming task. To streamline and simplify this process, you can set up a workflow rule that will trigger the automatic creation of purchase orders.

Here's how it works: Let's take the example of John, a retail business owner who has received an order. While he's in the process of creating the sales order, he notices 2 items whose stock levels need to be replenished to fulfill future orders. During the sales order creation in Zoho Books, John can simply use a checkbox-type custom field (specifically created for this purpose) to mark the items that need to be ordered. From that point, Zoho Books takes over.



The custom function is executed to generate purchase orders for all the marked items. The choice of vendor in the purchase orders is based on the preferred vendor assigned to each item. If there are multiple items in the sales order with the same preferred vendor, the system will consolidate these items and add them to a single purchase order.

Prerequisites: 

1. Create a check box-type custom field for the items by the name "Generate PO" to be displayed in the item table of sales orders. When creating a sales order, it's necessary to tick this checkbox to initiate the creation of a purchase order for the item.



2. It's important to fill in the "Preferred vendor" field in the item details screen so that the purchase orders are raised for the corresponding vendor. Do note that the "Preferred vendor" field will be displayed only when the Purchase information of the item is enabled.




3. Create a Connection named "zbooks" to successfully execute the function. You can watch the GIF attached below to know how to create the connection.



Custom Function:

Navigate to Settings -> Automation -> Workflow Actions -> Custom Functions -> +New Custom Function > Add the function code from this GitHub link.
 
Workflow Rule: 
 
Go to Settings -> Automation -> Workflow Rules -> +New Workflow Rule and set up the workflow rule as shown below:-





In the final step of this workflow rule, associate the custom function you created and then hit Save.

This function will not just be a time-saver but also help you maintain optimum inventory levels required to fulfill customer orders. Should you need any help in configuring this function, remember, that we're just an email away. Feel free to drop your queries to support[at]zohobooks[dot]com. We're always available to provide the assistance you need! 

Regards,
Shireen Farhana S
Zoho Books

    Access your files securely from anywhere

        All-in-one knowledge management and training platform for your employees and customers.






                              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

                                                                                                                • date & datetime client script getInput types

                                                                                                                  Please add date & datetime as available types for the getInput client script function. https://www.zohocrm.dev/explore/client-script/clientapi/Client#getInput
                                                                                                                • Opt-out from mailing list means can't email at all??

                                                                                                                  It seems that if a contact unsubscribes from a mailing list the only way to email them is to uncheck the email opt-out box first, then re-check after the email has been sent. I've been through a chat with support and they confirmed this. This seems bizarre. Many of my clients don't want to receive a monthly newsletter but they definitely want to be in email communication with me, often on a daily basis. Any thoughts out there?
                                                                                                                • Email Opt Out Question

                                                                                                                  Has the problem where if a customer is emailed opt out prevents you sending standard emails? For me this feature is simply to stop any email marketing and should not block people from receiving emails via Zoho mobile, which makes no sense.
                                                                                                                • Multi-currency and Products

                                                                                                                  One of the main reasons I have gone down the Zoho route is because I need multi-currency support. However, I find that products can only be priced in the home currency, We sell to the US and UK. However, we maintain different price lists for each. There
                                                                                                                • Approval Workflow Not Triggering When Status Updated via Custom Button

                                                                                                                  Hi Team, I’m facing an issue with an approval workflow in my application. I have a workflow that updates a record’s Status field from “Pending” to “Waiting for Approval.” I have configured an Approval Workflow with the condition: Status = "Waiting for
                                                                                                                • Zoho TeamInbox stuck / unusable – possible orphaned organization?

                                                                                                                  Hi all, I’m running into an issue with Zoho TeamInbox under Zoho One Trial and wondering if anyone has seen this before. We’re trying to set up a shared inbox for orders (orders@), but TeamInbox appears to be in a broken state: • The app does not load
                                                                                                                • Audio transcript not working in Zoho notebook

                                                                                                                  Greetings all! I'm enjoying the Zoho notebook as I tested out over other notebook applications. I would really love the audio transcripts to work as that would save us a lot of time so that we can utilize the notes from an audio recording. Currently when
                                                                                                                • Re: Application Architecture in Zoho Creator — A Platform-Specific Deep Dive

                                                                                                                  A recent community post on application architecture made some excellent points about planning architecture early in Zoho Creator projects. The core message is right — Creator applications have a habit of growing organically into maintenance nightmares,
                                                                                                                • Schedule Timeout 5 minutes vs. stated 15 minutes

                                                                                                                  I am running into a function run timeout error after 5 minutes for my schedules. The Functions - Limits documents states it should be 15 minutes: Functions - Limits | Online Help - Zoho CRM. What should it actually be? Due to the 5 minute timeout, I'm
                                                                                                                • 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
                                                                                                                • Placeholders in Ticket Templates

                                                                                                                  We should be able to use placeholders in ticket templates. When we create a new ticket, our description field is shown to the client in the email they receive.  It would be very handy to be able to personalize that description field in our ticket templates to pull in the name of the client that the ticket is for. Using them in the subject field as well, so we can auto populate Account Names, etc. 
                                                                                                                • Favorite Views list sort order?

                                                                                                                  Is there a way to rearrange the Favorite Views list?
                                                                                                                • Will I see emails sent via campaigns in CRM?

                                                                                                                  It would be useful for people to be able to see emails sent via campagins in Zoho CRM is that possible?
                                                                                                                • Introducing Product Catalog in Bigin

                                                                                                                  Greetings, I hope all of you are doing well. For many small businesses, sharing products and collecting customer interest often involves multiple tools, manual follow-ups, or even building a full ecommerce website. To address this challenge, we're excited
                                                                                                                • Products in Email Template

                                                                                                                  I’m a little confused as to how to add the listed products, from within a specific deal, to an email template. I want to generate said email template when a deal reaches a specific stage and include the products that have been selected for the deal in
                                                                                                                • Option for - CSV Export from Pipeline Deals by Stage (Including Products, Companies, and Contacts)

                                                                                                                  I would like to know when we will be able to export a simple CSV file from pipeline deals, with the option to select a specific stage within the pipeline. This export should include data for products, companies, and contacts, all in a single view. For
                                                                                                                • Zoho Billing Partial Proration...

                                                                                                                  Hi, In Zoho billing, we offer upgrades, downgrades, suspends, and resumes. We use online payment for most subscriptions, but have only a few that are offline, but we treat them the same either way.. We prorate only parts of these changes.. Right now zoho
                                                                                                                • Announcing Zoho Sheet desktop app for macOS and Windows (Beta)

                                                                                                                  Hello Sheet users, We know you’ve been waiting for this one. It has always been the top priority on our roadmap to provide a single native desktop app for macOS and Windows that works both online and offline. Today, we are excited to announce that the
                                                                                                                • What is the maximum length/size of a presentation on Apple TV?

                                                                                                                  Hello, I have a presentation here that I regularly show on Apple TV. It’s always the same presentation, which keeps getting longer and more extensive over time. Almost every slide contains a graphic or photo that takes up the entire slide. That means:
                                                                                                                • CRM Notes

                                                                                                                  Hello, We want to add a Note to the Contact record when a Note is added to a Case or Deal. I wasn't able to do this using a workflow, so I tried using Zoho Flow, but that didn't work either. Does anyone have a suggestion on how we can accomplish thi
                                                                                                                • Zoho Books | Product updates | April 2026

                                                                                                                  Hello users, Welcome to our April 2026 product updates roundup! Highlights include profit margin for sales transactions, insights in reports, recording deposits from undeposited funds in banking, and faster production workflows with improved assembly
                                                                                                                • Sorter View No Longer Works Properly

                                                                                                                  Today I realized that sorter view no longer works properly. I believe just yesterday, I was able to drag a slide or a group of slides and move it/them to the place I want to move it/them to. While I was dragging, I got a visual feedback of where I could
                                                                                                                • Ignroe_filtrers and drill through

                                                                                                                  I have two charts, where one is connected to the other using drill-through. The issue is with the second chart (the drill-through target). It contains an aggregation formula that uses the ignore_filters function. Under normal conditions, the formula works
                                                                                                                • zoho creator panel add formula

                                                                                                                  Hello. I'm using zoho panels which works good for me but i need to add an extra calculation the predefined sum function provided by zoho. not sure if this is possible? The code zoho is generating for the sum is as follows; <text margin='0px' padding='0px'
                                                                                                                • Kaizen #238: Fetching Employee Data from Microsoft SQL Server into Zoho CRM Using Queries

                                                                                                                  Hello everyone! Welcome back to the Kaizen series! Many organizations manage workforce data such as employee designations, contact details, salary bands, and joining dates in an HRMS backed by Microsoft SQL Server, while their sales teams work in Zoho
                                                                                                                • Du prompt à la production : comprendre le fonctionnement du MCP

                                                                                                                  Le Model Context Protocol (MCP) est un protocole ouvert qui standardise la manière dont les applications se connectent aux modèles de langage (LLM). En termes simples, le MCP est le « USB-C des agents IA » : une interface universelle qui relie l’intelligence
                                                                                                                • Add Flexible Recurrence Options for Meeting Scheduling in Zoho Cliq (e.g., Every 2 Weeks)

                                                                                                                  Hello Zoho Cliq Team, We hope you are doing well. Currently, when scheduling a meeting inside Zoho Cliq, the recurrence options are limited to Daily, Weekly, Monthly, and Yearly. There is no ability to set a meeting to occur every X weeks — for example,
                                                                                                                • filter on sheets mobile (iOS, iPadOS) does not work

                                                                                                                  re-posting this as a question because reporting as a problem netted zero responses... I have this issue on every spreadsheet, whether imported or created natively in Zoho Sheets. I can use on desktop without issue: but on iOS the filter dropdowns are
                                                                                                                • Inactive License for free account.

                                                                                                                  I recently upgraded my Cliq subscription not my team (on the free version), are unable to login to their accounts. The error message received is Inactive License Looks like you have not been covered under the current free plan of users. Please contact
                                                                                                                • Zoho Books recurring invoicing link to a Zoho CRM Deal?

                                                                                                                  With the Zoho CRM Finance Integration setup, normally when creating an invoice via Zoho CRM Finance Integration on a Deal, it creates the invoice in Zoho Books with the CRM Deal *Potential link for that invoice. Alternatively, if you create the invoice
                                                                                                                • Data Import

                                                                                                                  Hello Latha, Is there any option to enable data import option in Equipment module? Best regards, Chethiya.
                                                                                                                • No background for video recordings, no playback speed, can't even playback longer recordings - have to download…

                                                                                                                  Hi. We utilize heavily video messages on Slack, but wanted to migrate to Cliq with Zoho One, however very basic yet very frequently used feature is missing: backgrounds for video recordings and playback speed. We were not happy with Slack's 5 minute limits
                                                                                                                • Introducing PDF conversion in Deluge

                                                                                                                  Hello everyone, We're pleased to introduce built-in PDF conversion capabilities in Deluge with the launch of the convertToPDF task. As PDF is one of the most widely used formats in professional environments, this task helps streamline document generation
                                                                                                                • Changing naming convention for Estimates

                                                                                                                  Hi there, How do I customise the naming of the filenames for estimates when sending them? Currently they are named literally just ES11.PDF or whatever the number of the estimate is. There is no Company name, description of the work, customer name, date
                                                                                                                • Email templates for estimates

                                                                                                                  Hi there, When I send an estimate the option to choose a template appears. However it is common to need to make some minor personalizations and modifications to the email before sending ie. adding a second person to the greeting, or adding a small note
                                                                                                                • How to transfer uploaded files from Zoho Survey to external systems?

                                                                                                                  Hi everyone, I'm currently integrating Zoho Survey with an external system and have run into a limitation I haven't been able to solve yet. I'm using webhooks to send submitted survey data (JSON) to my external API, which works perfectly for all standard
                                                                                                                • On Duty Requests - Zoho People Data

                                                                                                                  Hello Team, We are currently using the On Duty Form to record Work From Home (WFH) requests in our organization. However, we are facing an issue where pending On Duty requests are not appearing in the Attendance Module. For example, if I submit On Duty
                                                                                                                • Editing Estimates

                                                                                                                  Hi team, How do I delete line items in an estimate when editing it? I can't see any option to do this - no X, no trashcan, no drop down... And how do I revert to the original estimate after cloning? I cloned to see if the option to edit were disabled
                                                                                                                • Reading emails sent from Zoho

                                                                                                                  Hi there, How do I view an email sent from Zoho, for example an email which contains an estimate? I can see there is a tab in the screen for that estimate which is labelled 'Emails' and I can see a summary of the email sent listed there, but I cannot
                                                                                                                • Feature Request: Mass update selected Contacts to Accounts

                                                                                                                  I can't believe this isn't an ability already. It's a quick fix that would save hours of manual entry time. This looks like it had been requested 3-4 years ago with no answers from staff! Please add all contact fields into the "mass update" menu. You
                                                                                                                • Next Page