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

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

        • Recent Topics

        • Convert Item to composite item

          When using Zoho CRM integrated with Zoho Inventory/Books, the item creation process is a little messy. After a few years of trial and error, we have settled on creating items in CRM, which are sync'ed to Zoho Inventory using Zoho's own internal integration.
        • 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
        • Mapping “Account Name” from CRM to Campaigns

          I’m syncing our Contacts list to Campaigns and want to select “Account Name” as an available field. Account Name does not appear in the drop down menu for CRM field even though Account Name is a field in our standard layout. How can I make it availa
        • Zoho Campaigns to Zoho Analytics Sync Fails – Field Mapping Shows But Not Applied

          I’m facing a persistent issue with the Zoho Campaigns integration to Zoho Analytics in my workspace. Here’s a detailed description of the problem: Under Edit Setup, I see a field mapping summary that shows: DataField Mapping: Most Recent Login However,
        • How to link web sales payments through Stripe to invoices?

          I have just set up an online shop website which accepts payments through Stripe.  The payment appears in Zoho Books through the Stripe feed as 'Sales without invoices'.  In order to keep Zoho Inventory in step, I manually (for now) create a Sales Invoice
        • Partially receive PO without partial Bill?

          Most of our inventory is pre-paid. Let's say we purchase 30 pieces of 3 different items for a total of 90 pieces. It is common for our supplier to send us the items as they are ready. So we will receive 30 pieces at a time. How can I partially receive
        • 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
        • Host in US Data Centre

          I humble apply to be registered on US Data centre
        • Zoho People & Zoho CRM Calendar

          Hi, Does anyone know if it is possible to link Zoho People and the calendar in CRM? I would like when holidays are approved they automatically appear in the calendar on CRM. Thanks 
        • Secure your external sharing process with OTP Authentication

          For any business, it's crucial to share files externally in a way that is both secure and controlled. Let's say you want to share confidential data with your partners and vendors. You must ensure that only your intended recipients can access the shared
        • Reply to email addresses wrong.

          I have setup my Zoho mail account using my main domain and I also have an Alias setup from a different domain. In Settings - Mail - Compose I have selected to the option "For replies, send using The same email address to which the email was sent to". This seems to work perfectly, except that the email always sends the email with a Reply To email address from the main domain not the alias. This can be changed in the Reply To drop down box to the right of the From Address in the email, but I obviously
        • Multiple images, one record

          I have a form that is used to capture the following info: -Facility Name -Origin -Shipment # -Picture of Damaged Pallet (Image field) I want to be able to capture multiple pictures without having to create a new record, as there might be multiple damaged pallets on the shipment. Obviously, one never knows how many damaged pallets might be on a shipment so I'd prefer not to create 20 image fields and have most of them unused.  I'd prefer that they have an option to add another image only if they need
        • how to dynamically upload multiple images for single record?

          Is the use of dynamic multiple images in a single record supported? I've searched but have not found the answer. If it is supported, how is it done? I saw 1 suggestion to add a sub-form but that doesn't seem to be the answer. I don't want to add a set number of image fields. Each record would have a different number of images. I want the addition of images to be dynamic. thanks
        • Multi-upload field

          Hi I need to include a file upload field that allows the user to select multiple files and upload all at once. I hope I can do this with HTML, I'm new to merging HTML and deluge... Can I trigger a hidden file upload window to appear On User Input of a field in an embedded form? Thanks! Levi
        • is it possible to add multiple attachments to a record?

          Hello, I'm trying to add functionality so that a record can have several associated attachments. I obviously added a File Upload field to my form, but that appears to only allow one total. Is there a way around this? Thanks, - Kevin
        • multiple upload files in zoho form

          Hi,  I need upload multiple files  in a single upload field thkns
        • Multi file upload

          Hi, I just wonder if one could upload multiple files in one shot, say between one and three files, without adding multiple File Upload fields? Thanks, Alalbany
        • How to rename the Submit Button by using deluge script

          Hi everyone, As we know, the Submit button can be renamed in the form builder setting. But I have scenario where I need the Submit Button to be renamed differently according to condition. Anyone knows how to do it? Thank You
        • Zoho Inventory Feature Roadmap Visible To All

          Hello, please consider making your feature roadmap visible to us users so that we know what to expect in future. This may appease current users who are seeking clarification on feature implementation dates, so that they can make an informed decision whether
        • Can't find parent child ticketing

          Hi I can't find parent child ticketing under tickets in this new organization... I have in the past on other organizations
        • What's New in Zoho Invoice | April - June 2025

          Hello everyone! We're excited to share the latest feature updates and enhancements we've made to Zoho Invoice from April to June 2025. In this, you will learn more about the following features: New Integrations via Zoho Marketplace Add Images to Email
        • Keeping Track of Email Threads

          Hi, Z CRM is great for tracking all the activities one would want to track whilst qualifying leads, converting to customers, closing deals etc etc, however.... ....although I can use Z CRM to send an email to a lead/contact and have that recorded as an activity for other team members to see, there is no way of capturing an inbound email from that lead. Assume my lead replies to my email sent from ZCRM, in my case, the response arrives in my ZMail account. However I can't get it back into ZCRM to
        • Zoho Creator invokeUrl to retreive PDF

          I'm trying to retreive a record PDF to send to Print Node. Tried with and without the zoho_creator_connection. pdf_content = invokeurl [ url :"https://creatorapp.zoho.com.au/<org_namespace>/<app_link_name>/record-pdf/<report_link_name>/" + input.ID type
        • Bulk upload image option in Zoho Commerce

          I dont know if I am not looking into it properly but is there no option to bulk upload images along with the products? Like after you upload the products, I will have to upload images one by one again? Can someone help me out here? And what should I enter
        • How to Automate Monthly PDF Reports with Filters in Zoho Creator

          Hi everyone, I’m trying to build an automated monthly reporting process in Zoho Creator and would appreciate suggestions or best practices from anyone who has done something similar. What I’m trying to do: I have a form called New_Customer with fields
        • Zoho App Builder

          I’m looking for a Zoho Creator developer to build a simple app for tracking site expenses for a construction company. Key features: mobile form, dropdowns for projects and expense types, photo attachment for invoices, auto-calculated totals, and Excel
        • Captcha can't be enabled conditionally

          Hi Problem: captcha on a form can't be enabled conditionally. Why is this a problem: Because I use the same form on our website (public) in the portal and mobile app. In the portal it works but in the mobile app it doesn't. So there should be a way to
        • Enhancements in Portal User Group creation flow

          Hello everyone, Before introducing new Portal features, here are some changes to the UI of Portals page to improve the user experience. Some tabs and options have been repositioned so that users can better access the functionalities of the feature. From
        • ACH Returns Don’t Trigger Dunning or Reverse Payment in Zoho Subscriptions

          Zoho Billing marked an ACH payment as successful and kept the subscription active — even though the payment was later returned by the bank (NSF). There was no update to the invoice or subscription status, and I had to manually clean it all up. For credit
        • Zoho Sheet - Split cell diagonally fill half color

          is it possible to split a cell diagonally, fill different text in each half and ideally color them differently as well?
        • Adding a work order for Assets vs. changing the contact person

          When adding a work order for an existing Assets (e.g. service), the assigned contact cannot be changed (deleting the contact deletes the selected Assets). This results in such an illogical operation that if you want to change the person to be contacted,
        • How to handle this process need using a Blueprint?

          See one minute screen recording: https://workdrive.zohoexternal.com/external/eb743d2f4cde414c715224fc557aaefeb84f12268f7f3859a7de821bcc4fbe15
        • bulk scheduling youtube shorts and facebook reels

          how do i flag the video as facebook reel rather than normal video, it's vertical, 20 seconds, yet still being posted as video on facebook for youtube, it's being rejected out right both videos are to standard, can be posted normally with normal scheduler
        • Invitation-Based User Access in Zoho Analytics

          Hello everyone, We’re rolling out an important update on how users are added to your Zoho Analytics Organization and Workspaces. Previously, when admins added users, they were automatically added to the organization. Moving forward, to improve security
        • Add Comprehensive Accessibility Features to Zoho Desk Help Center for End Users

          Hello Zoho Desk Team, We hope you're doing well. We’d like to submit a feature request to enhance the client-facing Help Center in Zoho Desk with comprehensive accessibility features, similar to those already available on the agent interface. 🎯 Current
        • "Recently Changed Payload Format" for webhooks in Zoho Billing

          We are seeing a message about recently changed payload format for webhooks in zoho billing. I cannot find any notification about this change can you give me more information on this?
        • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

          Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
        • Filtert products by multi select custom field

          Hello, this is seems like a must addition, why it can not be done now?
        • Multiple images

          Hi Is there a way to insert multiple images in one image record or any way that instead of one image, I could upload 5 to 10 images together. Looking forward for a solution. Regards
        • Cannot delete old accounts

          Hello, I try to delete old accounts from CRM, but it won't permit, saying documents are still linked to them. I searched in CRM and BOOKS, found some documents and deleted them, but still CRM won't delete them. Any idea how to do that ? I have a lot of
        • Next Page