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
    • 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,
    • Function-2: Round-Robin assignment of records

      Welcome back folks! Last week, we saw how to update sales commission in quotes using a custom function. This week, let's see an interesting use case asked by many of you - auto-assignment records by round-robin method. Business scenario: Right now, the solution allows you to auto-assign leads from web form and imported lists. Let us look at a need where you want to auto-assign leads from in-bound calls in a round-robin method, across modules. Prerequisite: You must create a permanent record in the
    • Recent Topics

    • Change Default Coutry in country field

      Hi, Is it possible to set a default country in the country field ? It's very borring to set-it each time...
    • Totals on Pivot Table

      Is there a way to change the way the subtotal calculates? In this example I have a formula to give me the average monthly attendance ....but I want the grand total of the month to be the sum of all the average attendances...any ideas? Thank you!@
    • Getting error for invalid session on zoho mail

      Since yesterday I am getting following error when I am trying to log in on zoho mail your session is invalid. you will be logged out in 3 seconds!!  Can someone please help me how to fix this? Thanks Manoj
    • How to add the time duration for scheldule call

      Hi, When we are planning phone calls with leads or customers. Depending on the client, lead and the reason for the call the time planned is always different from 15 minutes to 2 hours. Currently, the system does not allow us to change or add a time duration
    • Zoho Zepto mail

      I've already checked the domain and setup the user agent, as well as the SMTP user name and password, and the test email is working. So, please teach me how to import an email list and send emails.
    • Parsing Emails to save attachments

      Hi there, is there a way to get all attachments on emails (Zoho Mail Add on) saved as 'Attachments' on Zoho automatically?
    • Function Only Working Manually

      Good evening everyone. I have a function that creates a PDF from a Creator form. When I execute it manually it works perfectly. But when I execute it from within a On success workflow it is not working. I'll post my code below. Any ideas? //Function void
    • How to send binary data in invokeurl task?

      Hello, I am using Adobe's Protect PDF API. Source: https://developer.adobe.com/document-services/docs/overview/pdf-services-api/ Everything works fine in Postman. But for some reason after encrypting the file, it is empty after password protecting the
    • Caso de Uso | ZKTeco ahorra cientos de horas al año con Zoho One

      "Zoho no solo ha facilitado nuestro día a día, sino que se ha convertido en un aliado de negocio estratégico para ZKTeco." - Emilio García, CTO ZKTeco Europa ¡Hola, Español Zoho Community! Hoy nos gustaría mostraros cómo el gigante de la tecnología de
    • Set up multiple IMAP email addresses

      Hi, I just started using CRM and its great, but I just found out I can only add one imap email address for incoming mail in the included salesinbox ...this is ridiculous. All companies have different email such as sales@domain, info@domain , personal@domain
    • CRM - Copy data from Single Line to Lookup Field

      Hello, I need help to create a workflow with a custom function in order to copy value from a single value field to a Lookup Field. Module : Shipment Single value field API name : Customer_ID Lookup field API name : Account_ID WOuld be great to have some
    • How long until received item is visable as in stock when creating bundle?

      We just moved to zoho, and we notice when an item is received from a PO, it is not yet available to be used in a bundle. Is there a time delay, or some other reason it will show in stock, but not show in stock in the bundle?
    • LinkedIn Followers not correct

      It looks like Zoho Analytics only counts followers from the day it was connected to our LinkedIn-page. The Total Followers Count in Analytics only displays 549 followers, while in reality we have 1,036 followers. The information is correct in Zoho Social,
    • Add multiple users to a task

      When I´m assigning a task it is almost always related to more than one person. Practical situation: When a client request some improvement the related department opens the task with the situation and people related to it as the client itself, the salesman
    • Stock Count

      The stock count is a nice new feature, but we cannot figure out how to: 1. Use it without assigning to a person, we have a team or one of multiple do stock counts as do most any company. 2. Add any extra fields to what the "counter" sees. The most important
    • Lookup Fields - Needs more than 5 Link

      The lookup field is useful, but it 100% needs more than 5 field merge links. Can Zoho increase this to 10?
    • Disabling Tasks module- Zoho Projects app update

      Hello everyone! In the latest Android(v3.9.19) and iOS(v3.9.6) versions of the Zoho Projects mobile app, we have implemented enabling/ disabling the Task module as per your portal configuration on the Zoho Projects desktop site(projects.zoho.com). If
    • Free webinar alert! The Art of Virtual First Impressions: Professional Etiquette with Zoho Workplace.

      Hello, community members! We're delighted to invite you to our first webinar of 2025, The Art of Virtual First Impressions: Professional Etiquette with Zoho Workplace, on January 23. The effective usage of Zoho Workplace isn't just about the tools—it’s
    • WhatsApp in Zoho Social

      Seems CRM team is not taking Whatsapp integration seriously. While Facebook already has 63 Whatsapp partners, some of which are very small, that have already completed API integration. Maybe the social team could take over this project from CRM and get
    • Zoho Analytics in 2024: A look back

      Happy new year to everyone in the Zoho Analytics community! As we welcome 2025, here's a look back of important happenings in 2024.
    • Emmanuel Katto : Zoho Meetings Outlook Plugin Authentication Issue - Help Needed

      Hi everyone, I'm Emmanuel Katto, We’ve been facing an issue with the Zoho Meetings Outlook plugin for the last couple of weeks. When we try to sign in via the plugin, it redirects to the authentication page, and after successfully authenticating, it shows
    • Search Function Not Working Properly

      Search Function Not Working Properly
    • Mapping for date field from one module to another.

      Hi there, I want to be able to map a date field(due date) in a module (sales order) to another module's(Purchase Requisition) date field(Promised customer date). Is this possible when the due date field is a zoho system date field while the promised customer
    • Nimble enhancements to WhatsApp for Business integration in Zoho CRM: Enjoy context and clarity in business messaging

      Dear Customers, We hope you're well! WhatsApp for business is a renowned business messaging platform that takes your business closer to your customers; it gives your business the power of personalized outreach. Using the WhatsApp for Business integration
    • Convert Sales order to Delivery Challan

      Dear Developer Team, In Zoho books we cannot convert sales order into delivery challan before making invoices. As a service business we have to get the delivery note signed then only we can make the invoice. In Some cases we don't receive a purchase order
    • Zoho Commerce - Mobile Application

      Does Zoho Commerce have a mobile application for customers to place an order?
    • Global "Search" in FSM

      I'm missing the global Search function like in CRM. This should save us a lot of time. We don't now upfront if the customer is a Contact or a Company. So now we have to guess in what module to start a search/filter. Also looking up an address, phone number,
    • Unable to send message; Reason: 554 5.1.8 Email Outgoing Blocked

      My account is mino@flawless-frames.com, or flawlessframesstudio@gmail.com Could you please unblock my account, I've got restricted from sending more emails
    • Which are the IP addresses to use for 'split delivery' with Office 365? (Zoho mail inbound gateway)

      Hi, I'm trying to set up 'split delivery' (email routing) with Office 365. I'm following the instructions to set up Office 365 as the primary server (https://www.zoho.com/mail/help/adminconsole/coexistence-with-office365.html) One of the prerequisites
    • This domain is not allowed to add. Please contact support-as@zohocorp.com for further details

      I am trying to setup the free version of Zoho Mail. When I tried to add my domain, theselfreunion.com I got the error message that is the subject of this Topic. I've read your other community forum topics, and this is NOT a free domain. So what is the
    • Bulk Importing Personal/Shared contacts via csv or excel

      Hi, Is there a way we can add multiple contacts or import a contact list to the personal or shared inbox? Please assist
    • Can we have Bills of Material Module ?

      Can we have Bills of Material Module ?
    • Domain verification is in progress... (How long do I need to wait?)

      Trying to setup my first email domain by connecting with GoDaddy. Have been here for quite some time and the screen is not changing. How long should this take?Send DataSend Data
    • Fixed asset management

      I want to know if there is any individual module for fixed assets management
    • How to sync read mails to GMail?

      Hello I am testing Zoho TeamInbox but I have an issue with my connected GMail account. Whenever I read a mail in TeamInbox or even reply to it, the email stays as "unread" in GMail. Is this normal behaviour? I thought that with the 2-way sync of IMAP
    • Lost ZB Code

      Hi, Please what is the ZB code for my domain? It was mistakenly deleted. Please treat as urgent.
    • Unblock ME

      info@pentekykloi.gr Unable to send message;Reason:554 5.1.8 Email Outgoing Blocked. Learn more. I purchase additional storage
    • My email id is blocked. My storage is exceeded 5GB. Deleted unwanted emails.

      My email id is prem@justbootup.com. I tried to unblock ,but it says only for the paid user. Can you help to unblock?.
    • How to Recall emails send from Teaminbox

      How to Recall emails send from Teaminbox ?
    • Zoho Analytics - Data source timezone

      Hi, I have a Zoho Desk data source that should display date information / timestamps in Europe/Paris timezone (CET/CEST). However, as shown in the attached screenshot, the data source is using America/Mexico_City timezone despite having my Locale Information
    • Next Page