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

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

        • Recent Topics

        • How do I see what participants see when I am app sharing in a meeting?

          How do I see what participants see when I am app sharing in a meeting? In my view, I only see myself as active, but not the app (keynote on mac)
        • Pending Dispatch Status on Transfer Order TO

          Hello, when our branches request stock, we initiate a TO which puts the item into a "In Transit" status otherwise someone else may try to sell that item, which could be problematic if the item has limited quantities. The problem is that if the item has
        • Zoho Desk's ASAP announcement | Time to embrace the enhanced JWT Authentication Mechanism for ASAP | Dec'23

          Hi All, We are eager to introduce the enhanced JWT authentication mechanism for accessing your ASAP add-ons. Effective December 25th, 2023, the ASAP's old JWT authentication mechanism will be deprecated. This means that the option to switch to the new
        • Trying to copy Active Leads to a Custom Module called Dead Leads

          Hi, I am trying to code when the "Active Lead Status" field is changed to "Dead", a copy of the record should be created in the "Dead Leads" module while keeping the original lead in "Active Leads." I am using the following code but I keep getting the
        • Blocking an email address

          Hi How do I block an email address in my Zoho mail? Thanks Brian 
        • Zoho Desk add OIDC federation for 3rd party IDP

          Please consider adding the ability to use OIDC/OAuth compliant Identity Providers to Zoho Desk. You currently have Zoho, Microsoft, LinkedIn, Google and Facebook. But if you added the ability to use ANY OIDC compliant provider, you would add compatibility
        • Cliq funtion not triggerring from Books.

          Gentlemen, I have been requesting the Zoho Books team for 15 days through various emails- then even escalated. The response that I get from Zoho is " Our back-end team is working on it......." It is a template-type response. I authenticated the link(Cliq
        • Tracking Agent Diligence in Updating Records

          Our organization mainly focus on B2B. While we've implemented automations like pushing info from web forms into CRM, we often get info from events and individual networks. The complete/updated info relies in the agents who directly interacts with them,
        • how to create a company without an assigned owner

          In my company we are reassigning accounts and we need to leave some companies without an owner to review their potential and then assign them, but the options that appear in owner require that they be assigned to a seller, how to leave them without an
        • Stop selling out of stock Items.

          Hi I have been using Zohobooks for a around 8 month now. I am not involved in selling process but my staff cant stop selling product which they do not hold in stock, this is a big headache for me as physical count never matches what is shown on the books. 
        • Matrix dropdown

          Is there a way to create a matrix question with dropdown answers but 1 row correlates to 1 column? So really I want to combine 4 dropdown questions into 1 matrix but each question has a single, and different, dropdown for answers.
        • Managing Rental Inventory in Zoho

          Can Zoho Inventory manage rental inventory efficiently, or is there another Zoho app that would be better suited for this kind of operation? Looking for advice on the best approach. Thanks in advance.
        • Code API récupération enquêtes et documents

          Bonjour peut-on générer des codes API avec Zoho Survey ou Forms afin de récupérer des questionnaires existants sur nos autres outils ? Comment procéder ? Faut-il disposer d'un abonnement particulier ?
        • Field Updated based off Call Status

          I'm trying to create a Field Update where: When Call Status is Completed Lead/Contact/Account Description field with the information in the "Outcome Of Outgoing Call" Description field. Once our sales team finishes their calls and they add a description
        • Exporting uploaded files in bulk on Zoho Survey?

          Hi, I have a survey that includes an image upload field, I'd like to be able to export the individual responses in bulk, but it appears only the name of the image uploaded, and not the image itself gets exported. Any way to have the images be exported
        • Is there API Doc for Zoho Survey?

          Hi everyone, Is there API doc for Zoho Survey? Currently evaluating a solution - use case to automate survey administration especially for internal use. But after a brief search, I couldn't find API doc for this. So I thought I should ask here. Than
        • Create Quote does not show the "Product Description" entered as part of the Product setup.

          The product description created as part of the product setup page, does not show in the Create Quote module; The module allows for an additional description to be added but without access to the original stored description. By selecting the product from the "Product Name Lookup" pop-up, the "Product Description" part should be populated from the product record where the user is allowed to further modify it.
        • How to convert Item to composite Item

          Dear Team, We need to convert Item to composite Item as Zoho is importing partial information from Shopify.
        • 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
        • Why wont Zoho Support Grammarly!! --- PLEASE VOTE FOR THIS to show Zoho we need this

          The spell check and grammar in ZOHO are so buggy and a waste of time. Please support Grammarly! I'm sure I'm not the only one — there are other CRMs that support this. If you're not planning to add this feature, Please let others know before accepting
        • Email Verification on Subdomain

          Hi, The latest guidelines for setting up an email newsletter are to set it up on a subdomain of your main domain so that if you get put in a spam block, it doesn't block all your company email. We have been trying to set this up and managed to get our
        • Phone Number Format Change - Bulk Add Country Code and Remove Dashes

          In the past I would create a new customer in my Zoho Books, and enter their phone number in the format customary for the USA (that's where we are domiciled): Areacode-Prefix-Number 234-456-6789 This scheme is important as many other software packages
        • 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.
        • Client Can't View Ticket

          Hi, I created a ticket for my Client since he had an issue. I added him as a Contact as well. My client got a notification in his email that the ticket has been created. When he went to view the ticket on his desktop, the screen was blank. He then viewed
        • Automating Custom Web Link Messages to Customers via Instant Messaging in Zoho Desk

          Hello, I am looking for assistance with Zoho Desk's Instant Messaging feature. Is there a way to automate the sending of a custom web link to customers every day at 6:30 PM? Any guidance or suggestions on how to achieve this would be greatly appreciated.
        • Categorise Attachments

          We take ID, proof of address, right to work documentation and more.  I can upload a single file in to field, but we often receive multiple files for each category e.g. someone may send a separate file for the front and back of their national ID card.  My team don't have time to manipulate the files in order to upload them as a single file. The options, as far as I can tell, would be to create additional fields on attachments in order to categorise what the file is, or to be able to upload single
        • How to autorespond for inactive users?

          Hi, we have a few inactive users that we would like to set up an autorespond to the sender telling that the email addresses are no longer active. How can we do that?
        • Mass Action Button Script

          Hi all, I've been trying to search a lot of places for a solution on how to do a button placed at the "Mass Action Menu" and thus only updating multiple CHOSEN records at once. After finding no success whatsoever, I decided to just run and test whatever
        • Error 553

          Hello how are you? I'm having trouble sending email. This message appears whenever I try to send an email. I'm receiving emails normally, but I just can't send them
        • Implement Regex in Layout and Validation rules

          Hello all, We are excited to announce that users can now implement Regular Expressions (Regex) in our layout and validation rules. This new functionality allows for more flexible rules to be created when designing and validating forms. What is Regex?
        • Zoho Desk Validation Rule Using Custom Function

          Hi all, I tried to find the way to validate fields using custom function just like in Zoho CRM but to no avail. Is there a way to do this?
        • Confirmation prompt before a custom button action is triggered

          Have you ever created a custom button and just hoped that you/your users are prompted first to confirm the action? Well, Zoho knows this concept. For example, in blueprint, whenever we want to advance to the next state by clicking the transition, it is
        • How do we add Google Analytics code to Zoho Bookings scheduling pages or the thank you page?

          We need to track user activity on individual Bookings' pages and/or the thank you pages? How do we do this?
        • Zoho Sheets working offline

          Hi,  I am looking for the ability to work offline in Zoho Sheets, but currently I cannot find the process to complete this.  Does someone have any ideas or steps I might have missed?  Also does Zoho Sheets have the "Format as Tables" function as is currently in MS Excel 2016??  Many thanks. 
        • Repeating Sections in Writer

          I am wondering if it's possible to create repeating sections or text boxes of a document based on a merged subform fields coming from Zoho Forms. We are currently using excel to dynamically create a legal PDF document based on input fields in another
        • Add Knowledge Base KB Articles to multiple categories

          Greetings,  Love you help center system.  One item that would be incredibly helpful to many of us would be able to add a single Knowledge Base KB article to multiple categories in our system.  It seems it could be quite easy to use a checkbox form, instead
        • Important update in Zoho Forms: Enhancements for improved email deliverability

          Hello, form builders! We would like to inform you about some changes we're making in Zoho Forms to ensure the deliverability of your outbound emails. Changes to Gmail policies Gmail has updated its DMARC policy which quarantines emails sent with gmail.com
        • Error 403: Forbidden When Updating Email Signature via API

          Hi Zoho Desk team, First, congratulations again on the excellent Zoho API. But, I’m encountering an issue while attempting to update an email signature via the API. Whenever I make a request to update the signature, the response returns an HTTP 403 Forbidden
        • Directly Edit, Filter, and Sort Subforms on the Details Page

          Hello everyone, As you know, subforms allow you to associate multiple line items with a single record, greatly enhancing your data organization. For example, a sales order subform neatly lists all products, their quantities, amounts, and other relevant
        • Lost the ability to sort by ticket owner

          Hi all, in the last week or so, we have lost the ability to sort tickets by Ticket Owner. Unlike the other columns which we can hover over and click on to sort, Ticket Owner is no longer clickable. Is it just us, or are other customers seeing this too?
        • Next Page