Function #37: Create a Purchase Order from a Quote

Function #37: Create a Purchase Order from a Quote



Welcome back everyone!

Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote.

Business scenario:

In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order, the actual transaction, transaction confirmation, etc also need to be documented. Zoho CRM provides you different modules specific to the business process. For instance, Deals module is for Negotiation, Quotes is for finalizing an agreement, Purchase Order is for customers to place orders for procurement of products or services and Sales Order is for confirmation of the transaction.

Going by the usual business process, negotiation comes first, followed by setting up an agreement and then the customer placing an order. In other words, you need to create a deal, quote and then a purchase order. Repeating the same procedure for many leads takes up a lot of your time.

What if you can save that time by making the record creation automated? Of course, you can still have a certain degree of control. For example, you can set a button to create a Purchase Order with information from a quote. Wouldn't that make your life simpler and save time?

Getting started with the custom function:
  1. Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
  2. Provide a name for the button. For example: "PO from Quote". Add a description(optional).
  3. Select the placement of the button as View page.
  4. Select the action to be performed as "Writing function".
  5. Copy the code given below.
  6. Click “Edit arguments”.
  7. Enter the name as “quote” and select the value as “Quote Id”.
  8. Click Save&Execute Script.
  9. Save the script.
  10. Select the profiles who can view this button.
  11. Click Save.
The Code:

respMap = zoho.crm._getRecordById("Quotes", input.quoteId.toLong());
productDet=ifnull(respMap.get("product"),"");
productList=productDet.toJSONList();
pdlist=List();
for each eachProd in productList
{
eachProdDet=eachProd.toMap();
productDesc=ifnull(eachProdDet.get("Product Description"),"");
quantity=ifnull(eachProdDet.get("Quantity"),"0");
listPrice=(ifnull(eachProdDet.get("List Price"),"0.0")).toDecimal();
netTotal=(ifnull(eachProdDet.get("Net Total"),"0.0")).toDecimal();
linediscount=(ifnull(eachProdDet.get(("Discount")),"0.0")).toDecimal();
total=(ifnull(eachProdDet.get("Total"),"0.0")).toDecimal();
productId=ifnull(eachProdDet.get("Product Id"),"");
linetax=(ifnull(eachProdDet.get("Tax"),"")).toDecimal();
mp=map();
mp.put("Product Id",productId);
mp.put("Quantity",quantity);
mp.put("List Price",listPrice);
mp.put(("Discount"),linediscount);
mp.put("Total",total);
mp.put("Tax",linetax);
mp.put("Net Total",netTotal);
pdlist.add(mp);
}
paramap=map();
paramap.put("Products",pdlist);
paramap.put("Subject",ifnull(respMap.get("Subject"),""));
paramap.put("CONTACTID",ifnull(respMap.get("CONTACTID"),""));
paramap.put("Terms and Conditions",ifnull(respMap.get("Terms and Conditions"),""));
paramap.put("Description",ifnull(respMap.get("Description"),""));
paramap.put("Tax",(ifnull(respMap.get("Tax"),"0.0")).toDecimal());
paramap.put("Adjustment",(ifnull(respMap.get("Adjustment"),"0.0")).toDecimal());
paramap.put(("Discount"),(ifnull(respMap.get(("Discount")),"0.0")).toDecimal());
paramap.put("Sub Total",(ifnull(respMap.get("Sub Total"),"0.0")).toDecimal());
paramap.put("Grand Total",(ifnull(respMap.get("Grand Total"),"0.0")).toDecimal());
createResp = zoho.crm._create("PurchaseOrders", paramap);
return "PO created successfully";

Note:
  • The code is zoho.crm._getRelatedRecords for Version 1.0 of APIs.
Found this useful? Try it out and let me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful. Do check out other custom functions shared in this series here.

See you all next week with another interesting custom function. Ciao!

    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



                                                          • Sticky Posts

                                                          • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

                                                            Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
                                                          • User Tips: Auto-Create Opportunity/Deal upon Quote Save (PART 1)

                                                            Problem: We use quotes which convert to sales orders but Users / Sales Reps do not create opportunities / deals and go straight to creating a quote. This leads to poor reporting. Implementing this solution improves reporting and makes it easier for users.
                                                          • Custom Function : Automatically send the Quote to the related contact

                                                            Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
                                                          • Function #50: Schedule Calls to records

                                                            Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM
                                                          • Function #37: Create a Purchase Order from a Quote

                                                            Welcome back everyone! Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote. Business scenario: In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order,


                                                          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

                                                                                                          • Search handwriting using sketch card and OCR

                                                                                                            Hi It's possible using Sketch Card for handwriting and search them using AI and OCR in Pro edition? Thanks
                                                                                                          • Autoresponders in Zoho CRM will be discontinued—transition to Cadences for enhanced engagement

                                                                                                            Zoho CRM’s Autoresponder feature will be discontinued by September 30, 2025. If you're currently using Autoresponders to automate email follow-ups, we recommend switching to Cadences, a more powerful, flexible, and multi-channel engagement tool for today's
                                                                                                          • Recovering a note

                                                                                                            Hi, I accidentally deleted an important academic not from my notebook. Can I recover it? Thanks
                                                                                                          • Unable to schedule posts!

                                                                                                            Hi everyone, I'm on the free account. I just realised it doesn't give me the options to schedule posts anymore, I can only 'post now'. I don't understand why I can't even see what I scheduled before. Can anyone help? Thanks, Benedetta
                                                                                                          • ZUG is Hitting the Road — Across the USA!

                                                                                                            We’re bringing the Zoho User Group (ZUG) meet-ups back to various cities across the United States — and we’re more excited than ever to reconnect with our incredible community! Whether you're a seasoned Zoho user or just getting started, this event is
                                                                                                          • SPF, Zoho Books, Send from my domain

                                                                                                            I am unable to verify my domain through Zoho Books: this is the text record: v=spf1 include:spf.protection.outlook.com include:zohomail.com -all I waited 24 hours already with error: SPF record not found. Contact your domain provider.
                                                                                                          • How do I record timesheet invoices generated in Zoho Workerly against a Sales Order?

                                                                                                            We have customers who issue us a Purchase Order for an aggregate amount of hourly services, which we invoice against on a weekly, bi-weekly, or monthly basis (contract dependent). For simplicity, let's say the customer PO is for $50,000 (1,000 hours at
                                                                                                          • One Place for All Your Automation Needs

                                                                                                            All automation settings are grouped under Settings ()> Automation. This helps you find everything related to automation from one place. Under Workflow Rules, Email Alerts, Email Templates, and Webhooks: Use the Projects tab for project-specific settings.
                                                                                                          • How Do I Refund a Customer Directly to Their Credit Card?

                                                                                                            Hi, I use books to auto-charge my customers credit card. But when I create a credit note there doesn't seem to be a way to directly refund the amount back to their credit card. Is the only way to refund a credit note by doing it "offline" - or manually-
                                                                                                          • header and footer for templates

                                                                                                            Hi,   I created many templates for my activity. Nevertheless I have a big problem, the HTML is varies from a quote to another, there is sometime less or more text. In order to have a nice layout I require Header and Footer. I looked for into the CRM tool, couldn't find it. Can someone explain to me if it's possible ??   It's very urgent, thanks very much,   Eric Marois
                                                                                                          • Simple Text Search Function

                                                                                                            Would it be too much to ask for a simple text search function? My slide decks are often simply collections of slides of a random over, and I often have to find the slide I need at a moment's notice. A text search function, no matter how rudimentary, would
                                                                                                          • Rich-text fields in Zoho CRM

                                                                                                            Hello everyone, We're thrilled to announce an important enhancement that will significantly enhance the readability and formatting capabilities of your information: rich text options for multi-line fields. With this update, you can now enjoy a more versatile
                                                                                                          • Introducing the Reviews sub-module in Zoho Recruit

                                                                                                            Across every recruitment process, candidates are assessed by multiple stakeholders—recruiters, interviewers, hiring managers, and clients. These evaluations influence hiring decisions, yet they often exist in silos across assessments, emails, or interview
                                                                                                          • We need customizable sub-form layouts

                                                                                                            Currently, we can arrange sub-form fields only in a single row. The single row layout means salespeople must horizontally scroll to uncover information. As a result, salespeople cannot see all of the relevant information simultaneously.  The administrator
                                                                                                          • Fetch function not working for CRM Contacts

                                                                                                            I've created a flow that checks if a contact exists in CRM (based on form input), and if it does, then it updates one of the fields for the contact. In my test, the fetch function correctly identifies that a contact exists (based on email address), but
                                                                                                          • How to add a discount (percent %) field?

                                                                                                            My particular case it’s regarding the “Opportunities” module. I’ve created a subform to calculate the value of the opportunity, and now I’d like to include a discount field in the form of a percentage. However, no matter how or where I add the "percent"
                                                                                                          • Automate Pricebook per Customer

                                                                                                            Example Scenario: I want to create a customer package (Silver Package, Gold Package, Platinum Package) and associated it with a Price Book that contains discounted prices for certain products. When a customer assigned to this Silver Package places an
                                                                                                          • Automate pricebook per customer

                                                                                                            Example Scenario: I want to create a customer package (Silver Package, Gold Package, Platinum Package) and associated it with a Price Book that contains discounted prices for certain products. When a customer assigned to this Silver Package places an
                                                                                                          • Automate pricebook per customer

                                                                                                            Example Scenario: I want to create a customer package (Silver Package, Gold Package, Platinum Package) and associated it with a Price Book that contains discounted prices for certain products. When a customer assigned to this Silver Package places an
                                                                                                          • Client Side Scripts for Meetings Module

                                                                                                            Will zoho please add client side scripting support to the meetings module? Our workflow requires most meeting details have a specific format to work with other software we have. So we rely on a custom function to auto fill certain things. We currently
                                                                                                          • Document Tracking

                                                                                                            Hi all Zoho crmplus user here. I am migrating from hubspot and in Hubspot when my sales team email a document they can see when the client has opened the document and how many minutes they sepend on it. This persists for additional openings and readings
                                                                                                          • Apply partial payments to invoices from the Banking Module

                                                                                                            We need this! Why is this not possible?
                                                                                                          • Forecast UI improvements

                                                                                                            Hi I have two improvement requests for the UI in the Forecast function. Can you add the ability to reorganise the Pipeline, Committed and Best Case columns on the Forecast? I thought they were in alphabetical order, so we renamed them so that we could
                                                                                                          • Missing services/ features / buttons

                                                                                                            Hello, 1. I can't locate the DKIM information in ZoHo CRM that I need to add as txt strings to our DNS in GoDaddy. 2. In other activities I cannot locate the 'Help' button for context senstivie help 3. I wish to merge two records into a single record
                                                                                                          • Global Sets for Multi-Select pick lists

                                                                                                            When is this feature coming to Zoho CRM? It would be very useful now we have got used to having it for the normal pick lists.
                                                                                                          • [Free Webinar] Building Data Relationships Using Lookup Fields - Creator Tech Connect

                                                                                                            Hello Everyone! We welcome you all to the upcoming free webinar on the Creator Tech Connect Series. The Creator Tech Connect series is a free monthly webinar that runs for around 45 minutes. It comprises technical sessions in which we delve deep into
                                                                                                          • Staff Tracking in

                                                                                                            Hi , I would like to see what activity my staff does over Zoho CRM and over Zoho Mail . I need to know which deals in CRM haven't been touched or had an activity on by a particular staff member . Basically need to establish what work.gets done by WFH
                                                                                                          • Is there a way to force a page refresh after changing a Subform via Workflow / Function?

                                                                                                            I have a workflow which triggers a function, and in this function i am changing the values of a certain subform. The changed are only visibile when i manually refresh the page and this is a no-no for my use-case. When other workflows, that change certain
                                                                                                          • Allow non admins to create folders

                                                                                                            I want to allow users in my company to create their own reporting based upon selected Datasources, however they currently can't create folders to save their work in. This can only be done by admins, which seems excessive. Is this possible ?
                                                                                                          • Episode I : Exploring the World of Custom Functions in Zoho Desk

                                                                                                            Hello Again! Welcome to an Automation Adventure in the World of Zoho Desk Join us on a journey to explore how custom functions can enhance and extend the capabilities of Zoho Desk. Automation is everywhere. From robotic arms assembling products on factory
                                                                                                          • Free Webinar - Overview of Zoho Sign and latest updates- May 2025

                                                                                                            Hello there! What's the digital alternative to endless paperwork? Zoho Sign. Designed for digital-first businesses, Zoho Sign is a complete digital signature solution with powerful features and seamless integrations that streamline your entire workflow.
                                                                                                          • Multiple Forecast configurations

                                                                                                            Hi all Is it possible to have multiple Forecast Configurations? That is, not just multiple forecasts, but rather different forecasts assigned to different configurations? The use case here is that we currently have the Forecast module configured for Revenue
                                                                                                          • Discussions from Ask The Experts 19: Inside Zoho Desk Spring Release 2025 : Zia in Focus

                                                                                                            Hello everyone, We had insightful discussions in both the sessions of Ask the Experts(ATE) 19, diving deep into engaging conversations around Zia and the spring release. Your enthusiastic participation and thought-provoking questions brought the sessions
                                                                                                          • Basic campaign set-up

                                                                                                            I have been trying hard to get Zoho CRM and Zoho Mail connected, but somewhere I seem to have wires loose in my brain. I'm not winning. Could anyone just show me (1) how to set up a scheduled email campaign (test to only six internal staff), (2) how to
                                                                                                          • Add template Categories Qoutes sendmale

                                                                                                            Is there other way to add other template categories in sendmail qoute?
                                                                                                          • What’s New in Zoho Inventory | April 2025

                                                                                                            Hello users, April has been a big month in Zoho Inventory! We’ve rolled out powerful new features to help you streamline production, optimise stock management, and tailor your workflows. While several updates bring helpful enhancements, three major additions
                                                                                                          • Report categories not appearing in pie chart

                                                                                                            I have created a simple report to display all of the accounts in our CRM in a certain region, broken down by their 'account type' field. I have displayed this data as a donut chart Highlighted in red in the top left, you can see there are a total of 968
                                                                                                          • Asking for the implementation roadmap or step-by-step guide

                                                                                                            Hello everyone, I'm a freelancer who's been hired to implement Zoho CRM for a client, and I want to make sure I approach this correctly. Could someone kindly share a comprehensive implementation roadmap or step-by-step guide that covers all the essential
                                                                                                          • Recurring Events Not Appearing in "My Events" and therefore not syncing with Google Apps

                                                                                                            We use the Google Sync functionality for our events, and it appears to have been working fine except: I've created a set of recurring events that I noticed were missing from my Google Apps calendar. Upon further research, it appears this is occurring
                                                                                                          • Custom Function to Format Phone / Mobile numbers in Australian Standard format

                                                                                                            So I got sick of phone numbers being formatted incorrectly and Zoho not doing anything to standardise phone numbers to meet E.164 formats. So I went and coded my own function to fix this. And figured I'd share with the community This is specifically for
                                                                                                          • Next Page