Auto-convert a quote into a sales order

Convert a deal's quote into a sales order automatically every time a picklist field is modified in a deal record.

You can convert quotes into sales orders using the default convert option located within the deal record of your CRM account. What if you want to automate the conversion process through workflow rules? For example, let's say you want to convert a quote (found in the related list) into a sales order automatically every time a custom picklist field is modified in a deal record. This is when our low-code tools can come in handy.

To convert quotes associated with a deal into sales orders, you can create a custom function and connect it to a workflow rule in the Deals module. Once this is done, you can automatically convert quotes into sales orders if certain predetermined conditions are fulfilled in the deal record.

Permissions and availability

  • Users with the Manage Automation permission can create and update workflow rules.
  • Users with the Manage Extensibility permission can write custom functions.
  • Users with the Manage Sandbox permission can manage the sandbox.

Requirements

  • Create a workflow rule for the Deals module to convert their quotes into sales orders. Learn more
  • Write a custom Deluge function and link it up with the workflow rule. Learn more
  • Test the workflow rule in a sandbox before deploying it in your production environment. Learn more

Create a workflow rule

Follow the steps below to create a workflow rule in your Zoho CRM account:

  1. Navigate to Setup > Workflow Rules > +Create Rule.
  2. Select the Module as Deals from the drop-down list.
  3. Provide a name for the rule. For example: "Convert quotes into sales orders". 
  4. Add a description (optional), then click Next.
  5. In the Execute this workflow rule based on section, choose Record Action, then select Edit from the drop-down.
  6. Select Specific field(s) get modified and specify the picklist field and its corresponding value.
  7. In the Which deals would you like to apply the rule to? section, select to trigger this workflow for all deals or set conditions for specific deals and click Next.
  8. Under Instant Actions, select Function and Write your own.
  9. Provide a Name and description, if necessary, for the function.
  10. On the Deluge Script Editor, do the following:
    1. Copy and paste the code given below.
    2. Click Edit Arguments.
    3. Choose Deal Id and name it as dealId, then click Save.
    4. Click Save & Execute Script.
  11. Click Save on the workflow rule page.
Create Workflow Rule

The code

Code Copied
relatedquotes = zoho.crm.getRelatedRecords("Quotes","Deals",dealId.toLong());
info relatedquotes;
for each  respMap in relatedquotes
{
	quoteId = respMap.get("id");
	productDet = ifnull(respMap.get("Product_Details"),"");
	pdlist = List();
	for each  eachProd in productDet
	{
		productvalue = eachProd.get("product");
		proid = productvalue.get("id");
		proname = productvalue.get("name");
		mp = Map();
		mp.put("product",{"name":proname,"id":proid});
		mp.put("quantity",ifnull(eachProd.get("quantity"),"0").toLong());
		mp.put("list_price",ifnull(eachProd.get("list_price"),"0.0").toDecimal());
		mp.put("discount",ifnull(eachProd.get("discount"),"0.0").toDecimal());
		mp.put("total",ifnull(eachProd.get("total"),"0.0").toDecimal());
		mp.put("net_total",ifnull(eachProd.get("net_total"),"0.0").toDecimal());
		pdlist.add(mp);
	}
	paramap = Map();
	paramap.put("Product_Details",pdlist);
	paramap.put("Subject",ifnull(respMap.get("Subject"),""));
	paramap.put("Contact_Name",ifnull(respMap.get("Contact_Name"),"").get("id"));
	paramap.put("Account_Name",ifnull(respMap.get("Account_Name"),"").get("id"));
	paramap.put("Deal_Name",ifnull(respMap.get("Deal_Name"),"").get("id"));
	paramap.put("Terms_and_Conditions",ifnull(respMap.get("Terms_and_Conditions"),""));
	paramap.put("Description",ifnull(respMap.get("Description"),""));
	paramap.put("Adjustment",ifnull(respMap.get("Adjustment"),"0.0").toDecimal());
	paramap.put("Discount",ifnull(respMap.get("Discount"),"0.0").toDecimal());
	paramap.put("Quote_Name",quoteId);
	createResp = zoho.crm.createRecord("Sales_Orders",paramap);
	info createResp;
}

Notes

  • Make sure to use the accurate API names for their corresponding fields in the code snippet. Learn more
  • This function helps you link the sales order to the quote by mapping the quote name with its quote ID, giving you the same outcome as if you manually converted.

Test the solution

  1. Go to the Deals module and click on the desired deal.
  2. In the Deal Details page, edit the picklist field and enter the value as per the workflow rule.
    The workflow rule will be triggered.
  3. Check whether the quote from the deal's related list gets successfully converted into a sales order.

Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.

More info

  • ModuleDeals
  • Trigger PointWorkflow Rule
  • EditionEnterprise and above
  • ComplexityMedium
  • Implementation Time30 minutes

Features used in the solution

Custom FieldWorkflow RuleDeluge ScriptSandbox
Story Image

Looking for a custom solution?

Contact us, we will help enhance your productivity at lightning speed.

SUBMIT REQUEST

Developers: Share your solution with our community!