Create deals for quote records

Create a deal for a quote, update the quote with the deal, and redirect the user to the deal page with the click of a button in your CRM.

Many businesses follow a standard sales process that involves creating a quote from a deal. However, some, especially in B2B, prefer to generate quotes before committing to a deal. Once a customer approves the quote, they create a deal to track negotiations and complete the sale. In these cases, the team creates a deal directly from the quote record. However, there is no straightforward way to transfer all the relevant context from the quote to the deal except for copying and pasting information manually, which will take forever. But now there's a solution!

To spare you the effort of manual work, you can create a custom button coupled with a function that creates a deal record for a quote at the click of a button. Additionally, it updates the quote with the newly created deal and redirects the user to the deal page. Read on to learn more.

Permissions and availability

  • Users with the Modules Customization permission can create custom buttons.
  • Users with the Manage Extensibility permission can write custom functions.
  • Users with the Manage Sandbox permission can manage the sandbox.

Requirements

  • Create and link the button with the custom function, as detailed in the "Create Button" section below. Learn more
  • Test the function in a sandbox before deploying it in your production environment. Learn more

Create a button

Follow the steps below to create a custom button in your Zoho CRM account:

  1. Navigate to Setup > Customization > Modules and Fields > Leads > Buttons > Create New Button.
  2. Provide a name for the button. For example: "Create Deal".
    Add a description (optional).
  3. Choose the layouts in which you want the button to be placed.
  4. Specify the button's placement as In Record and its position on the page as Details.
  5. Select the action to be performed as Writing Function.
  6. Provide a name and display name for the function, then click Create.
  7. In the Deluge script editor, do the following:
    1. Copy and paste the code provided below.
    2. Click Edit Arguments.
    3. Enter the name as quoteid and select the value as Quotes - Quote Id.
    4. Save the function.
  8. Select the profiles who can view this custom button.
  9. Click Save.

The code

Code Copied
quote = zoho.crm.getRecordById("Quotes",quoteid);
subject = quote.get("Subject");
subform = quote.get("Product_Details");
sublist = List();
for each rec in subform
{
	prod_name = rec.get("product").get("id");
	quantity = rec.get("quantity");
	list_price = rec.get("list_price");
	mp = Map();
	mp.put("Product_Name",prod_name);
	mp.put("Launch_Quantity",quantity);
	mp.put("List_Price",list_price);
	sublist.add(mp);
}
account = quote.get("Account_Name").get("id");
contact = quote.get("Contact_Name").get("id");
mp = Map();
mp.put("Deal_Name",subform.get(0).get("product").get("name"));
mp.put("Ordered_Item",sublist);
mp.put("Account_Name",account);
mp.put("Contact_Name",contact);
create = zoho.crm.createRecord("Deals",mp);
info create;
if(create.containKey("id"))
{
	deal_id = create.get("id");
	upd = zoho.crm.updateRecord("Quotes",quoteid,{"Deal_Name":deal_id});
	info upd;
	msg = "Deal created successfully";
	openUrl("xxxxx" + deal_id,"same window");
}
else
{
	msg = create;
}
return msg;

Notes

  • Replace 'xxxxx' with the URL of the deals module in your CRM account. For example, https://crm.zoho.com/crm/org1234567890/tab/Potentials/.
  • Make sure to use the accurate API names for their corresponding fields (e.g., "Deal Name") in the code snippet. Learn more
  • You can customize the code to include additional quote details in the deal record.
  • Upon creating a deal, the solution will update it in the quote record and open the deal in a new tab within the same window.
  • The above script is an example of creating a deal for a quote record at the click of a button. You can use this code to create deals from any other module, such as custom, by modifying the module name and parameters.

Tip

  • Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.

Test the solution

  1. Navigate to the Quotes module.
  2. Open a quote record for which you want to create a deal.
  3. On the Quote Details page, click the button you added to the page in the top-right corner.
    The deal record will be created and opened in a new tab.
  4. Check whether the deal record includes all the required quote-related information as specified in the code snippet. Additionally, confirm whether the quote record has its deal name updated.

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

  • ModuleQuotes
  • Trigger PointCustom Button
  • EditionEnterprise and above
  • ComplexityMedium
  • Implementation Time30 minutes

Features used in the solution

Custom ButtonDeluge 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!