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!


      Zoho Campaigns Resources


        • 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,

          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

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

                              Zoho CRM コンテンツ








                                ご検討中の方

                                  • Recent Topics

                                  • How can I setup Zoho MCP with Chat GPT

                                    I can set up custom connections with Chat GPT but I cat an error when I try to set it up. The error is: "This MCP server can't be used by ChatGPT to search information because it doesn't implement our specification: search action not found" Thoughts?
                                  • Group Tax in Service Line Items

                                    Hi FSM Team! I noticed that when you update a tax in the service line item the group tax is not showing up as an option. Let me know what can be done thank you!
                                  • Zoho Campaigns - Why do contacts have owners?

                                    When searching for contacts in Zoho Campaigns I am sometimes caught out when I don't select the filter option "Inactive users". So it appears that I have some contacts missing, until I realise that I need to select that option. Campaigns Support have
                                  • FSM Improvement Idea - Show an Import button when there is no data

                                    I am setting up FSM for a client and I noticed that there is no option to import data, see screenshot below. Even when you click Create Contact there is only an option to Import from Zoho Invoice. It is only after you add at lease 1 record that the Import
                                  • Whatsapp Limitation Questions

                                    Good day, I would like to find out about the functionality or possibility of all the below points within the Zoho/WhatsApp integration. Will WhatsApp buttons ever be possible in the future? Will WhatsApp Re-directs to different users be possible based
                                  • Zoho FSM API Delete Record

                                    Hi FSM Team, It would be great if you could delete a record via API. Thank you,
                                  • Transition from Sole Proprietorship to GmbH (Limited Liability Company) – Best Approach in Zoho Books / Zoho One

                                    Hello everyone, I am currently operating under a Zoho One plan with a sole proprietorship in Switzerland. As of January 1st, 2026, I will be incorporating a new legal entity – a GmbH (Swiss equivalent of a Limited Liability Company). While the business
                                  • Insert auto number from main form into subform rows

                                    Hello. I'm trying to take from my main form "order number" which i have setup as an auto generated number into every line created in my subform. So when a row is created in my subform i want the "order number " from the main form to be inserted automatically.
                                  • How to check Leads with no Task (open activity)

                                    Hi everyone, I was wondering if there’s a way to view leads that don’t have any tasks assigned or open activities linked to them.
                                  • Adding a developer for editing the client application with a single user license

                                    Hi, I want to know that I as a developer I developed one application and handed over to the customer who is using the application on a single user license. Now after6 months customer came back to me and needs some changes in the application. Can a customer
                                  • Function #4: Schedule Customer Statements

                                    Regularly sending statements to customers is an imperative part of many business processes as it helps foster strong customer relationships and provides timely guidance on payments. While you can generate the statement of accounts and have it sent over
                                  • Limiting search or dependencies with an asterisk "*".

                                    I have a form with several dependency fields with options still developing for each field. Since these options were developing and not yet ready to be a selection in the field, I placed a filter for the dropdown field. In this filter, I selected fields
                                  • Collaps Notes

                                    There are times when long/large notes are added to a record i.e. Accounts or Deals etc. Currently, the full note is displayed in the notes related list section. It would be great if by default only 5 to 10 rows of the note are displayed when the note
                                  • Improved RingCentral Integration

                                    We’d like to request an enhancement to the current RingCentral integration with Zoho. RingCentral now automatically generates call transcripts and AI-based call summaries (AI Notes) for each call, which are extremely helpful for support and sales teams.
                                  • Using Zoho Desk to support ISMS process

                                    Hi, I am evaluating using Zoho Desk for security incident management. This seems to be aligned with Zoho Desk purpose as its just another type of incident. However in security incident management, ideally I can link incidents (tickets) with a risk from
                                  • How to overcome limitations in meetings

                                    As a company, one of our deliverables is a meeting between two other companies, where we act as facilitators. So, if we recorded this meeting  in Zoho CRM, it should be connected to 2 accounts, 2 contacts, and 1 campaign (a campaign, in our use, is the
                                  • Cross Data Center Support for 1:1 Chats with External Users

                                    Hello Zoho Cliq Team, We hope you're doing well. We appreciate the recent enhancement that enables cross data center collaboration in external channels, which has already improved communication across distributed teams. However, we’ve noticed that this
                                  • What can we do on our end to improve the Answer bot answers?

                                    Hi, I'm using the Answer bot card in the Codeless bot builder. I've input several questions and their answers in the FAQ section to feed the Answer bot. The text is all in French, as this is the language our customers communicate in. I've tried testing
                                  • Support Bots and Automations in External Channels

                                    Hello Zoho Cliq Team, How are you? We actively use Zoho Cliq for collaboration, including with our external developers. For this purpose, external channels are a key tool since they work seamlessly within the same interface as all of our other channels
                                  • Answer Bot and Personalized Questions

                                    Hi there, I have the same problem using the SalesIQ Answer Bot and the Zoho Desk Answer Bot (which really need different names, to be honest, in order to avoid confusion...) Customers that visit our website ask questions in the form of "What do you do?"
                                  • Handling Greetings/Small Talk at the Beginning of a Zobot Conversation

                                    Hello everyone, I’m currently configuring a **Zobot** in Zoho SalesIQ and everything is working as expected, except for one specific scenario at the very beginning of the conversation. My target audience has the habit of starting with a **greeting or
                                  • Regex in Zoho Mail custom filters is not supported - but it works!

                                    I recently asked Zoho for help using regex in Zoho Mail custom filters and was told it was NOT supported. This was surprising (and frustrating) as regex in Zoho Mail certainly works, although it does have some quirks* To encourage others, here are 3 regex
                                  • Importing a new list into campaigns

                                    I'm in the middle of switching my email platform to campaigns. I have a list that I want to import, and it overlaps with my existing Zoho CRM list. The fields in my Zoho CTM are more robust. Will this new list that I upload into my campaigns overwrite
                                  • Client Script Payload Size Bug

                                    var createParams = { "data": [{ "Name": "PS for PR 4050082000024714556", "Price_Request": { "id": "4050082000024714556" }, "Account": { "id": "4050082000021345001" }, "Deal": { "id": "4050082000023972001" }, "Owner": { "id": "4050082000007223004" }, "Approval_Status":
                                  • Webform & spam

                                    Hi, We set up 2 webform on our website, fowarding the content to Zoho CRM. Since it has been opened up, we are getting lot of spam message (for now about 20 a day). To lower the  amount of false new leads we added the captcha field and new enquieries are send to the Approval Leads list. However we still get some spam. Is there any "anti spam" mechanism built in Zoho CRM, or how is the best way to avoid these kind of spam ? Thanks
                                  • when I email a invoice how can i see it was sent and also were i can go to see all emails sent

                                    when I email a invoice how can i see it was sent and also were i can go to see all emails sent?
                                  • Kaizen #208 - Answering your Questions | Functions, AI and Extensions

                                    Hello Developers! Welcome back to a fresh week of Kaizen! We are grateful for your active participation in sharing feedback and queries for our 200th milestone. This week, we will answer the queries related to Functions and Extensions in Zoho CRM. 1.
                                  • Export Invoices to XML file

                                    Namaste! ZOHO suite of Apps is awesome and we as Partner, would like to use and implement the app´s from the Financial suite like ZOHO Invoice, but, in Portugal, we can only use certified Invoice Software and for this reason, we need to develop/customize on top of ZOHO Invoice to create an XML file with specific information and after this, go to the government and certified the software. As soon as we have for example, ZOHO CRM integrated with ZOHO Invoice up and running, our business opportunities
                                  • Showing description in timesheet and timelogs.

                                    I am wondering if it’s possible in version 5 of Zoho People to have the description show by default or with a manipulation on the user’s part. Let me show you what I mean. As you can see this is the view for the users. Now if they want to see the full
                                  • How can I see content of system generated mails from zBooks?

                                    System generated mails for offers or invices appear in the mail tab of the designated customer. How can I view the content? It also doesn't appear in zMail sent folder.
                                  • Access Denied

                                    I am iOS Developer and updating our clients project and shifted ZohoDeskPortalCore SDKs from cocoapods to SPM and changed few lines of code but now i am get access denied, the help center app is unavailable. please contact administrator.
                                  • New in Cadences: WhatsApp follow-ups, upgraded limits, and options for add-ons

                                    Hello everyone, We're rolling out two key updates to help you engage better and scale smarter with Cadences in Zoho CRM. Reach customers on WhatsApp, directly from Cadences Previously, Cadences have enabled you to automate follow-ups through emails, calls,
                                  • Filtering Tickets based on Email headers

                                    We're starting to get a lot more junk coming into our Zoho Desk, which is then triggering unnecessary email alerts to agents. Once thing we could do to cut this junk in half, is to filter tickets based on email headers. Any email containing the `List-Unsubscribe`
                                  • CRM Blueprint Notification by Cliq

                                    Dear Zoho team, In Workflow, there is nofication by cliq, but in blueprint, there is no option as cliq notification. I think it is very convenient to get notified by Cliq , as there are multi modules in apps, but we will always check Cliqs
                                  • Zoho People Attendance Regularization – Wrong Total Hours Displayed

                                    While using Zoho People, I observed that the attendance regularization is showing wrong total hours when applied to past dates. For example, if a check-in is added at 10:00 AM and check-out at 6:00 PM for a previous date, the system sometimes calculates
                                  • Sync Contacts in iOS

                                    What does the "Sync Contacts" feature in the iOS Zoho Mail app do?
                                  • Live webinar: Craft the ideal sales pitch deck with Show

                                    Every great sale starts with a great story. And your pitch deck? That’s where the story takes shape. But too often, these presentations end up looking generic, overloaded with text, or lacking structure. The good news is, it's easier to fix than you think!
                                  • Project Statuses

                                    Hi All, We have projects that sometimes may not make it through to completion. As such, they were being marked as "Cancelled". I noticed that these projects still show as "Active" though which seems counter intuitive. In fact, the only way I can get them
                                  • 👋 Welcome to the Zoho MCP Community

                                    Hello all, glad to have you here! This is your space for everything AI agents, MCP tools, and intelligent business apps. This community is for you — developers, partners, creators, and businesses exploring how agents can transform work. Whether you’re
                                  • Suitability of Zoho One (Single User License) for Multi-State GST Compliance & Cost Analysis

                                    Hello Zoho Team, I am an e-commerce business owner selling on platforms like Amazon, Flipkart, and Meesho, and I'm currently using their fulfillment warehouses. I have two GSTIN registrations and am planning to register for an additional 2-3 to expand
                                  • Next Page