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!

    • Sticky Posts

    • Function #46: Auto-Calculate Sales Margin on a Quote

      Welcome back everyone! Last week's function was about displaying the discount amount in words. This week, it's going to be about automatically calculating the sales margin for a particular quote, sales order or an invoice. Business scenario Where there is sales, there's also evaluation and competition between sales reps. A healthy rivalry helps to better motivate your employees to do smart work and close deals faster and more efficiently. But how does a sales rep get evaluated? 90% of the time, it's
    • 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
    • Recent Topics

    • Help: Capture full page URL in hidden field when same Zoho Form is embedded on multiple pages (iframe)

      Hi all, Goal Use one Zoho Form across multiple pages and record the exact page URL (incl. subdomain + path + hash) where the user submitted it. Example pages: https://www.example.com/cargo/ https://www.example.com/cargo/containers/#contact https://cargo.example.com/auto/
    • The All New Attendee App | Zoho Backstage

      The Zoho Backstage attendee app is the primary touchpoint for attendees, speakers, exhibitors, and sponsors during an event. It helps participants access event information, manage their schedules, connect with other participants, engage with exhibitors
    • Department Customization Copy/Paste

      Hello! I love the new customization of the layouts, rules and templates! However, we have several "departments" that operate similar and as I'm updating either ticket layout or workflow rules, I'm finding that I have to do it in each department. I would
    • Ticket status does not update upon layout change

      Hi team, I'm encountering an issue with ticket layouts and Blueprints in Zoho Desk and would like to understand whether this is expected behavior or a bug. Scenario I have two ticket layouts: Helpdesk Integration The Integration layout has its default
    • Assign account to a ticket created with WebToCase

      We use Zoho Desk. Our large client uses WebToCase form to submit tickets. I have two workflow rules: When a contact is created and its email ends with example.com, it runs a custom function, which assigns the new contact the right account Example with
    • The 3.1 biggest problems with Kiosk right now

      I can see a lot of promise in Kiosk, but it currently has limited functionality that makes it a bit of an ugly duckling. It's great at some things, but woeful at others, meaning people must rely on multiple tools within CRM for their business processes.
    • "code":3001 ["Failed to update data."]

      I would like to seek your expertise - I might be wrong on my approach also.. I highly appreciate your advice. 1 problem remains is when a new row was added on the existing one [from another form that trigger upon Successful form submission ], it gets
    • Zoho Team Inbox - roadmap

      Hi, would be good to understand the Teaminbox roadmap, in particular: 1. API / Zoho Deluge connections. We have a process where the each email needs to be either tagged or assigned daily. It would be great if we could automate a 5pm alert for any exemptions
    • Displaying only unread tickets in ticket view

      Hello, I was wondering if someone might be able to help me with this one. We use filters to display our ticket list, typically using a saved filter which displays the tickets which are overdue or due today. What I'd really like is another filter that
    • Zia Agents looks promising, but I still cannot deploy my first agent or connect WhatsApp after weeks of support tickets

      Hi Everyone, I am posting here because I am stuck and need practical help from someone who has successfully deployed a Zia Agent with WhatsApp. Zia Agents looks like a very promising product. I have watched the platform expand quickly, and I have noticed
    • Application-Level Save copy of sent emails

      It would be really helpful to be able to turn on/off the Save copy of sent emails at a per application level, so some applications can save in the sent folder and others don't.
    • how to get transcripts with speaker and time marks?

      Hello, I downloaded the transcript of a recent meeting and noticed that the TXT file does not bring the speaker name and the time mark. Is there any way to make it happen using ootb resources from Zoho Meeting? best
    • [IDEA] Bring Layout - Conditional Rules and Client Scripts to Zoho Books

      The problem We run Zoho Books with two e-invoicing integrations: myData (Greek tax authority, AADE) and PEPPOL (EU e-invoicing). Between the two, our Invoice form carries a large number of custom fields — document type codes, VAT exemption categories,
    • Don't send customer email when creating a ticket

      Hi Is there an easy way to stop the system sending an email to the customer when we manually create ticket.
    • You do not have sufficient permissions to perform this operation. Contact your administrator.

      When I attempt to log a call I initiate the +New Call and Start Calling and I click Answered Call in the popup dialog box that follows. Any attempt to save or close this dialog box results in "You do not have sufficient permissions to perform this operation. Contact your administrator." The only way I can get the popup to disappear is to refresh the page and it will go away. I have found others reporting this issue when they attempt to run reports.  Any suggestions? Thank you in advance for taking
    • Zoho CRM Layout Rules: Nine New Actions, Profile-Based Execution, and Interactive Preview

      Hello everyone, Availability: This feature is now available for customers in the JP and SA DCs. It is planned to be released for other customers in soon. We’re excited to announce powerful new enhancements to Layout Rules in Zoho CRM - a feature built
    • Zia Agents: quando a Inteligência Artificial do Zoho para de sugerir e passa a agir

      Decidi criar um artigo com um panorama prático sobre o que são os agentes do Zia Agents, como funcionam de verdade dentro do ecossistema Zoho e o que aprendi implementando um agente de qualificação de leads em produção. De onde veio a idéia do artigo?
    • Zoho Desk Android app update: Manage Custom Module records, View Record Counts for Sub Modules.

      Hello everyone! We have introduced an option to add, edit and delete Custom Module records within the Zoho Desk Android app. Now, you can also view the record counts for sub modules (Time Entry, Attachments, Activities) in the ticket details screen. Please
    • Automating CRM backup storage?

      Hi there, We've recently set up automatic backups for our Zoho CRM account. We were hoping that the backup functionality would not require any manual work on our end, but it seems that we are always required to download the backups ourselves, store them,
    • How to preserve Lead Creation Date, UTM parameters, and custom fields during Lead Conversion?

      We are optimizing our MQL journey. When converting leads to contacts/deals, we need to ensure that the original system Lead Creation Date and UTM tracking parameters (Source, Medium, Campaign) are not lost or archived, as our teams require them for accurate
    • Problem with currency field in Zoho CRM

      Hi Guys Zoho Books has a feature in currency fields that automatically converts decimal numbers with commas ( , ) to period format ( . ) when pasting them. For example: R$ 2,50 --> R$ 2.50 Is this behavior available in Zoho CRM? I couldn't find any configuration
    • Sub-projects

      Hi,  Can we create a sub-project.   Client1 1. project1     1.1 sub-project1    1.2 sub-project2 2. project2    2.1 sub-project1    2.2  sub-project2
    • Using Items from Books as product/plan Add-Ons

      Hey, It'll be great to use Items from Books as product/plan Add-Ons. Ed
    • Inspection Table

      Hello Latha, We created a job sheet that includes the new table (Inspection Table) which was introduced recently. However, agents are not able to see the rows in the inspection table. Could you please investigate this issue and get back to us? Please
    • Custom Button Creation from Layout Editor in Zoho CRM

      Hello All, Buttons in Zoho CRM act as triggers that perform a specific action when clicked. Zoho CRM includes a set of system buttons that help you carry out common actions with a single click. Beyond these, your organization can create custom buttons
    • Automatic login options for customer portal

      The customer portal is nice for zoho subscriptions, but there are no options to automatically login to it, so if a user is logged into their account inside of my product, I can't create a link that will let them login to their dashboard. Could we have
    • Square Payments for Subscriptions

      I'd love to be able to use Square Payments for Subscriptions with my customers. I already use it for Zoho Books Please have this considered. It would really help my business
    • Admin Logging in as another User

      How can a Super Admin login as another user. For example, I have a sales rep that is having issues with their Accounts and I want to view their Zoho Account with out having to do a GTM and sharing screens. Latest Update (27th April 2026): With the early
    • Add a MATRIX field to the forms creation

      Same as Zoho forms, we need a Matrix field in Zoho Creator forms, is very usefull
    • Discount Per Line Item

      We are a phone company. Sometimes, when we sign up customers, our sales team would like to provide recurring discounts on certain addons. Presently, we have no way of doing this so when we provide discounts, we are forced to simply reduce the price of
    • Introducing template migration: Move your Docusign templates to Zoho Sign in minutes

      Moving to a new e-signature tool usually comes with a catch: recreating every template from scratch. For teams that rely on dozens of carefully built templates—each with the right recipient roles, fields, and placements—that manual rework is often the
    • Error Code 2945 , PATTERN_NOT_MATCHED

      Hi, I am trying out Zoho Creator API.  However, I always get the following <response>     <code>2945</code>     <message>PATTERN_NOT_MATCHED</message> </response> However, error code list error as Invalid Ticket. I do not know what is wrong. 
    • Create a list of products and automatically associate them with new deals

      Hello, I have a store with WooCommerce, and I want to import orders into my pipeline. But I haven't found a way to import the order with the associated products. So, do I have to create the deals and then manually add the products to them? That's double
    • List of Mail Merge Templates via Deluge

      Hello, Is it possible to get a list of the mail merge templates I've created in CRM within a custom function? I want to retrieve them and put them in a dropdown list but all I get is a scopes error! Can anyone see where I'm going wrong? Is this even possible?
    • Zoho Advanced Analytics with Team Module support – Now includes teams, notes, and fields in reports & insights

      Greetings all, Advanced Analytics is now accessible via Zoho CRM's team modules, which means you can add team modules—plus their notes and fields—for inclusion in reports, insights, and other analytical functions. Alongside the standard and custom modules
    • WhatsApp conversations are no longer linked to existing threads after reconnecting the channel

      Hi everyone, We have an existing WhatsApp channel in Zoho Desk. We temporarily disabled it, renamed it, and then re-enabled it while reassigning our bot. Since then, all previous WhatsApp conversations are still visible in the history, but we can no longer
    • Zoho Assist Feature Update: July 2026

      Elevate to Admin Mode for iOS devices Technicians can now elevate an active session to Admin Mode directly from the iOS app. This feature lets the technician switch the remote computer from a standard user account to an admin account by entering credentials
    • Bulk deleting Zoho CRM records using Deluge, COQL and CRM API

      Hello everyone, During CRM implementations, data cleanup is a common task, especially after testing, migrations, imports, or integration development. I created a reusable Deluge function that performs bulk deletion using the Zoho CRM API. The approach:
    • Can't connect CalDAV

      ### Issue Summary Can't connect to my calendars using CalDAV and the URL `https://calendar.zoho.eu` ### Steps to Reproduce 1. Tried to connect on multiple devices, on multiple OS's (Android DAVx, Thunderbird, Gnome Calendar, Apple Caneldar). 2. When I
    • CRM x WorkDrive: We're rolling out the WorkDrive-powered file storage experience for existing users

      Release plan: Gradual rollout to customers without file storage add-ons, in this order: 1. Standalone CRM 2. CRM Plus and Zoho One DCs: All | Editions: All Available now for: - Standalone CRM accounts in Free and Standard editions without file storage
    • Next Page