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

    • Recent Topics

    • Can't get sender adress to work

      Hi, I am having some trouble getting the sender adress to work for responses on tickets. I would like to configure a sender adress that is different from the zohodesk emailadress that is normally used. These are the steps I have followed: 1. Add a new
    • Troubleshooting Delays in Zoho CRM Automation Workflows for Lead Status Updates

      Dear Zoho Community, I am refining a sales pipeline in Zoho CRM, implemented in May 2025, to enhance efficiency for a small business managing client leads. While the CRM effectively tracks leads, I am encountering delays in automation workflows that update
    • Zoho Sprints - Q2 updates for 2025

      Hello everyone! We’re excited to share the latest updates from Zoho Sprints for Q2 2025! This quarter, we rolled out a few highly-requested features designed to enhance collaboration and time management across your projects. Here's a look back at the
    • CRM Email Insights Not Working - Status not Changing

      I used to be able to see if a customer opened/read an email in CRM, but I no longer get those status changes inside their record. I have everything enabled and I am sending the email from CRM. The experience center has the status' enabled as well. Any
    • The use of Ticket statuses

      When your support team mark a ticket "Closed" before I had a time to check what your team has done on the ticket - I have to consider this as you consider the ticket closed even if I dont consider it closed. Which automatically produce a negative sentiment.
    • Canvas: Add Sections to Detail View

      Currently it is only possible to add fields to a canvas detail view. This makes Canvas hard to maintain, because everytime we add a field to our system, someone needs to go into the canvas view and add it there as well. This leads to additional work and
    • Sudden Layout Issue After Last CSS Update for ZML (Temporary Fix Inside)

      Hi, Our clients have noticed today that every section laid out with ZML suddenly shows an unwanted top padding/blank space that interrupts the user screens. It appears that Zoho has changed the default CSS for the .zcp-col.zcp-panel-rowtype-auto element.
    • "Replace" an existing version of CRM

      Hi all, I have a question, I saw an article about this once, but I now cannot find it. I am working with a client who has had their CRM in Zoho One built and extensively modified. But it is non-functional now, and rather than try and unpick the system,
    • Add an option to start zobot when user clicks the Chat with Us button

      I would like to have an option to start the zobot when user clicks on "Chat with us" button when chat widget is maximized
    • Data Import From a private PostgreSQL RDS Instance

      Hello All, I feel like the problem I am experiencing has been seen before; however, I am having a difficult time finding any solutions. Hoping the community has some insights. I am trying to import data from a PostgreSQL RDS instance that is behind an
    • Assistance Required: Authentication Error When Sending Credit Application Form

      Hi, I'm encountering an error message that states: "Authentication unsuccessful – the user credentials were incorrect." This occurs when I attempt to send the credit application form to our customers. I've attached the form I’m trying to send for your
    • Missing Fields in Lead Conversion Mapping

      I’ve been using Zoho CRM since 2013 to manage leads and convert them into contacts and jobs. When I convert a lead to a customer, I create a new contact and a job. Previously, this process automatically transferred key information from the lead to the
    • Allow selection of select inactive users in User data fields

      Hello, We sometimes need to select a previous employee that has an inactive account in the User data field. For example, when doing database cleanup and indicating actions are done by a certain employee that weren't filled out when they were part of the
    • CRM Kiosk - Action for GetRecords

      I have a Kiosk screen with GetRecords and want to use the selected records in a custom function. My particular case is to set a lookup value on the selected records. Generally speaking though, I want to work with the selected records in a function. I
    • Order Items

      Hi .. We have to implement orders with line but each line should have a separate record and not as a subform, does anyone have experience with that kind of solution what is the best practice for that kind of thing Thanks
    • How do I associate pricebooks to a customer?

      I setup a few pricebooks, that worked fine. But now the only thing I can do with it, when I enter a quote or sales order, I can select which pricebook to use, but I have to do this product by product every time I add one. Is there a way to connect a pricebook
    • Sync desktop folders instantly with WorkDrive TrueSync (Beta)

      Keeping your important files backed up and accessible has never been easier! With WorkDrive desktop app (TrueSync), you can now automatically sync specific desktop folders to WorkDrive Web, ensuring seamless, real-time updates across devices. Important:
    • Connection to Zoho One

      My org has a Zoho One account, which includes Zoho Social. We are wanting to try linkthread. However, I want to make sure it is set up properly from an account perspective, as I have accidentally created Zoho accounts separate from Zoho One when I didn't
    • Ticket Automatically Created from Closed Chat

      Is there a way to prevent a ticket being create for every chat.... or at the very least have it automatically closed.
    • IMPORT INVOICES CSV

      Hi, Impossible to import invoices in Zoho books with a csv file. I have also tried with the template. My topic keeps getting closed but I did not get any answer Is there an issue with this fonctionnality ?
    • 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
    • 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
    • Related Lists in Email Templates

      Hi Zoho team, I would love to see a feature where related list information can easily be added to an email template (instead of mail merge). I have a client who books flights for their customers. They do this through a Flights module so all booked flights
    • Zoho One - White Label

      Releasing a white-label feature for Zoho One, or any software or service, can offer several advantages and benefits for both the company providing the software (Zoho in this case) and its users. Here are some key reasons for releasing a white-label feature
    • Outlook plugin funktioniert nicht.

      DAs Outlook Plugin funktioniert nicht mehr. Ich werde aufgefordert, mich mit der App "OneAuth" anzumelden Intelligente Anmeldung per OneAuth funktioniert nicht zufreidenstellend. Nach erfolgreicher Anmeldungung mittels QR Code lande ich wieder beim QR
    • iOS App Version 3.0 - Customer list gone?

      Not sure when this changed, but I seem to have been updated to 3.0 for the phone app (on iOS). I'm pretty sure that I used to have a Customers button that allowed me, for example, to see what appointments a customer has. Has this disappeared or am I just
    • Zoho Signature, "For Demo Purpose Only Powered by Zoho Sign"

      How to disable this text on the documents for signature. "For Demo Purpose Only Powered by Zoho Sign"
    • Add Resource variable to notification email customisation for Event Type

      The notification email customisation feature for Event Type does not include a variable for the Resource field. Without this field, Zoho Bookings cannot be used by any business for resource-based services or event types e.g. room bookings, equipment bookings.
    • Can't find add role button, is iet st because I have the free subscription

      Trying to add my accountant in Zoho Books if I press the add accountant button, I get stuck as it says no such role exists, and won't let me continue, I can't find the add roles button, so I am stuck. Is it because I have the free subscription? Also can't
    • Calendar view all appointments in workspace

      In the Calendar page, add the ability to view all appointments in the Workspace. The Manage Calendars filter requires me to select at least one user or resource, and it only lets me select up to five of them. There's no filter option to view the entire
    • Tip #13: Identify where your bookings come from with Source Tracking

      Source tracking is the practice of identifying where your bookings originated. This is important, because online bookings come from a wide variety of sources like social media platforms, your website, email and ad campaigns, partner websites, organic
    • MS Teams for daily call operations

      Hello all, Our most anticipated and crucial update is finally here! Organizations using Microsoft Teams phone system can now integrate it effectively with Zoho CRM for tasks like dialling numbers and logging calls. We are enhancing our MS Teams functionality
    • Unable to Add Notes

      I've had a user report that they are unable to add notes to account records. I attempted and found the same issue. There is no option to save the note.
    • Workflow Rule Alert Not Working

      I have a workflow rule set (that I've been using for years) that suddenly stopped working. Module - Leads Execute on - Create Alerts - Email Active - Yes When I create my lead I no longer receive my email notification. 
    • Unify Overlapping Functionalities Across Zoho Products

      Hi Zoho One Team, We would like to raise a concern about the current overlap of core functionalities across various Zoho applications. While Zoho offers a rich suite of tools, many applications include similar or identical features—such as shift management,
    • Zoho Recruit > Job Opening Module> Editing, Deleting, Adding (Fields)

      Hello All In the Job Opening Modules How do i go about deleting the Positing Title or changing to Job Title or can i hide it from all? I want to add a Look Up User Field, however when i select the look up field i do not see that Can i have the industry
    • Assignment Thresholds Resetting After Lead Conversion

      Hello everyone, We're facing an issue with Zoho CRM's lead assignment thresholds that makes them unsuitable for our workflow. I'm hoping to find a potential workaround or solution from the community. Here’s our current process: A new lead is created automatically
    • Personal Link / Meeting ID

      with zoho meetings do I have my own personal link to my 'meeting space' ? I have an email template in Zoho CRM which confirms people's appointment with me, I would like to include the link to my Zoho Meetings so that they have it in advance. How do I
    • Help Needed with Creating Close % Reporting

      Now that our company has a good data set to work with we want to use ZCRM reports ways to track the performance metrics we have established. Specifically, I want to be able to calculate closing % for individual salespeople and individual support people.
    • Can zoho sign collect data feeding Zoho Sign?

      I m sending contracts to client who are not in my zoho CRM database yet. Can the data they enter in Zoho sign contract I send them, (that includes...) official company name address first name second name etc, ...Create or update a contact / account
    • Next Page