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

    • Rollup summary for custom module

      Rollup summary feature was introduced almost a year ago: https://help.zoho.com/portal/en/community/topic/introducing-rollup-summary-in-zoho-crm-public-early-access-2023 It does not support custom modules tough and this post aims to track such feature
    • Feature Request: Search in the PC client. Some thoughts about the search.

      Hi all. I'm really excited to start using Zoho Notebook, but I'm missing some of the search capabilities on my desktop. There are also some thoughts on improving search in general. Search is very important to me, without it it is difficult for me to use
    • Cannot use a Zoho Form in CRM Email Template

      I've created a Zoho form that has integration with Zoho CRM and is linked to a custom module. I know the form works as I have tested it. When I try and insert this Zoho Form in a button on a CRM email template set up with the same custom module I get
    • 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
    • Campaign email bounces and CRM entries

      Using campaigns.zoho.com and utilizing a sync'd list works fine.  But when emails bounce, they are removed from the campaign side, but there is no way to update the CRM record.    You can see that the email bounced in CRM by looking at campaigns-> member status, but you can not use that field to create a search or any other way in which to update those bad records.    I have a list of several thousand emails, and to update each record that bounces is a nightmare.  There has to be a way to utilize
    • Has anyone integrated SMS well for Zoho Desk?

      Our company does property management and needs to be able to handle inbound sms messages which create a ticket for Zoho Desk.  We then need to be able to reply back from Zoho desk which sends the user an sms message.  This seems like a fairly common thing to need - sms handling for support tickets.  There is basically no good information from any third party vendor for Zoho Desk, while there is a ton for CRM.  Zoho is pretty unhelpful when I've reached out to them, and a lot of vendors just direct
    • Tags When Importing

      My biggest wish right now for making Zoho Notebook easier to work with would be to have the ability to add tags while importing files/clips. This includes using the web clipper, adding web pages with Share on my phone, and adding pages by using Attach.
    • 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
    • Allow users to display columns dynamically

      I have a table with 50 users in Column A and the dates 1 Jan to 31 Dec along Row 1. I want users to be able to add data to the cells but would like to make it easier by allowing users to select a date and display that. So if the user wants to add data
    • Download fails

      We are unable to download data. When we try, we get the message "Download failed." We have two Bases. Downloads are working in one but not the other. The Base with the problem is 'Projects'. We're trying to download Time Records from the Month view. Note:
    • Webhook when estimate is refused is not firing

      Hello, I use a workflow through make that sends estimate with zoho books (I paid books and sign). -Those estimates when accepted are firing the webhook that I create in zoho sign (photo 1) -However when refused they are not firing the webhook that I created
    • RFQ MODEL

      A Request for quotation model is used for Purchase Inquiries to multiple vendors. The Item is Created and then selected to send it to various vendors , once the Prices are received , a comparative chart is made for the user. this will help Zoho books
    • Calculations in item custom field

      Dear Sirs,    Is it possible to do math inside items in Zoho Books? My item is a pack of plywood. Depending on thickness, there is certain amount of sheets in a pack and, as the result, different volume. I want to add fields like lenth, width, thickness,
    • I can't send and receieve any email ERROR CODE :550 - 5.7.26

      Hello, I can't receive and send any email for months. I already sent an email to Zoho support but didn't get any response. I attached a screenshot of a message i get always when i tried to send an email. Please help me asap.
    • Zoho Email Not Working After Domain Transfer and Nameserver Change

      Dear all, I hope you're all doing well. We recently transferred our domain, which is linked to Zoho, to another hosting provider. As part of the transfer, we updated the nameservers to the new hosting provider's ns1 and ns2. However, after this change,
    • Linkedin - Recruiter System Connect

      Hi there! Does anyone here know how to connect Zoho Recruit to Linkedin Recruiter via Recruiter System Connect?
    • 2025 Just Got More Exciting for Developers!

      Hello, Greetings to the Zoho Books Community! As we step into the New Year, we're thrilled to roll out something truly special for our Zoho Finance enthusiasts – the "Zoho Finance Developer" Community! This is your exclusive space to connect with fellow
    • Does Client Script work on Zoho CRM Portal?

      Hi ! I create a new module to use at customer portal. But Client Script looks not work. Please help me clarify, thank you!
    • Create custom rollup summary fields in Zoho CRM

      Hello everyone, In Zoho CRM, rollup summary fields have been essential tools for summarizing data across related records and enabling users to gain quick insights without having to jump across modules. Previously, only predefined summary functions were
    • Alter a system defined field from a 'single line' into a picklist

      Hello,  I am looking to switch the STATE field, which is a Zoho defined field from a 'single line' into a picklist. Can you advise how to change this?
    • SOLVED: Stopping Multiple Invitations when sync with Google Calendar

      I wanted to share this solution as I wasn't able to find it when searching through the Zoho community and via web search. The issue: When requestor books a meeting through Zoho Bookings, the requestor receives a confirmation email from both Bookings and
    • 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
    • Merging Writer Titles

      When merging from CRM into Writer, is there a way to add fields to the document header? This would be very helpful for saving. Is there a way to link the document automatically to the module?
    • Taxes... again.

      After reading the recent addition to the knowledge-base article at https://help.zoho.com/portal/en/kb/commerce/user-guide/settings/general-settings/articles/types-of-taxes, I feel compelled for the fourth year now to reiterate the glaring omission in
    • View tickets

      Is it possible to have 1 person in a organization which can view all tickets of that company? Example: IT Manager of Company X wants to view all tickets of Company X, no other user can see  all tickets of Company X.
    • Automatically associate contact with product

      Hello, I created a Real State scenario at CRM where I have property owners that are contacts, and properties that are products. After creating a contact and a product, I associated them. My Desk is integrated with my CRM, and it automatically creates
    • Zoho Desk Deluge get tickets info

      When using Deluge, Need to use "tickets" to obtain ticket information. Example : ticketDetails = zoho.desk.getRecordById(XXXXXX,"tickets",ticketId); Is there a way for me to query ticket information while only knowing "ticketNumber"? The "ticket Number"
    • What is the Desk API?

      I'm trying to fetch a lookup field data from desk to our creator application and it doesn't work. I'm guessing that my search parameter is wrong? On my trial function fetch if I use these: tickets = invokeurl [ url :"https://desk.zoho.com/api/v1/tickets/351081000145244764"
    • Zoho still running very slow

      I have a lead log for my company and creator seems to be running extremely slow still.
    • How to link Custom Fields in Ticket view

      Hi team, I have created 2 custom fields in our Accounts Module would like them to show in our ticket information. We don't have Enterprise so I cannot do it via a workflow, but I know you can do lookup fields to link modules. How would I go about making
    • Sending a Slideshow as a scheduled email

      I have created a slideshow for my dashboards - is there anyway of automating or scheduling it to send to users ?
    • How can I send out edm email without execced the mail limit and got block?

      Hello, What service should I subscribe and pay for?? Thanks Tomuel
    • 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,
    • Mapping of Zoho CRM Lookup field to CRM

      Hi, I have created a Zoho CRM Lookup field on a form for a client. The population of the field works great in the form however I cannot seem to get the data being entered in the form back into CRM. For example, the form is for new clients to fill in their
    • Lost Data

      I never synced it before but now since ir forced me to login... my data is lost. Can I still recover my local data?
    • Unable to verify Domain - Exabytes

      Hi, I have obtained a .com.my domain provided by Exabytes, but am unable to verify the domain ownership despite added in both TXT and CNAME as below: TXT - Name: @ ; Value: zoho-verification=zb88785805.zmverify.zoho.com CNAME - NAME: zb88785805 ; Value:
    • Enhanced Placeholder Preview for Templates

      Hi, When creating a new template in Zoho CRM, there are many variables/placeholders available, such as ${Organization.Organization Name} and ${Quotes.Created Time}. While these placeholders are useful, it is not always clear what each field represents,
    • Forgot password to my notebookd and notes

      Exactly what the title says. I know it sounds dumb since it's my own fault but what can I do? I'm just wondering if we can recover our password or something. I see there's no such feature but it should have right??? This is really frustrating to me because
    • Problems with email configuration and slowness in Zoho support.

      I've been having problems configuring emails since yesterday, they responded to me today, I sent a response right away and so far I haven't received a resolution to the problem. Attached are the configuration attempts that were made.
    • Next Page