It is practical for salespeople to create customized quotes for each deal to meet your customer's unique needs and preferences. However, what if your company only offers a limited number of products or always sells certain products as a bundle? An example would be pairing a television with a wall bracket or a soundbar. In such situations, generating a quote comprising the items listed in its corresponding deal's Products section can be beneficial. It saves time and effort to search for and add individual products whenever you create a quote.
As this scenario is a special requirement for most businesses, we support it through a custom button that you can add to the list view page of the Deals module. When you click this button, it opens a quote prefilled with products associated with the deal.
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
- Navigate to Setup > Customization > Modules and Fields > Deals > Buttons > Create New Button.
- Provide a name for the button. For example: "Create quote with products".
Add a description (optional). - Choose the layout(s) you want the button to be placed.
- Specify the button's placement as In Record and its position on the page as Details.
- Select the action to be performed as Writing Function.
- Provide a name and display name for the function, and click Create.
- On the Deluge Script Editor, do the following:
- Copy and paste the code provided below.
- Click Edit Arguments.
- Enter the name as potId, select the value as Deals - Deal Id, then click Save.
- Save the function.
- Select the profiles who can view this custom button.
- Click Save.
The code
potDetails = zoho.crm.getRecordById("Deals",potId.toLong());
RelatedProducts = zoho.crm.getRelatedRecords("Products","Deals",potId.toLong());
pdlist = List();
for each eachProd in RelatedProducts
{
proname = ifnull(eachProd.get("Product_Name"),"");
proid = ifnull(eachProd.get("id"),"");
mp = Map();
mp.put("product",{"name":proname,"id":proid});
mp.put("quantity",1);
mp.put("list_price",ifnull(eachProd.get("Unit_Price"),"0.0").toDecimal());
mp.put("product_description",ifnull(eachProd.get("Description"),""));
pdlist.add(mp);
}
paramap = Map();
paramap.put("Product_Details",pdlist);
paramap.put("Subject",ifnull(potDetails.get("Deal_Name"),""));
paramap.put("Owner",ifnull(potDetails.get("Owner"),"").get("id"));
if(ifnull(potDetails.get("Contact_Name"),"") != "")
{
paramap.put("Contact_Name",ifnull(potDetails.get("Contact_Name"),"").get("id"));
}
if(ifnull(potDetails.get("Account_Name"),"") != "")
{
paramap.put("Account_Name",ifnull(potDetails.get("Account_Name"),"").get("id"));
}
paramap.put("Deal_Name",ifnull(potDetails.get("id"),""));
createResp = zoho.crm.createRecord("Quotes",paramap);
info paramap;
info createResp;
return "Success";
Notes
- Make sure to use the accurate API names for their corresponding fields in the code snippet. Learn more
- The above script is an example of prefilling a quote with products associated with its deal record. You can use this code to prefill related products in an invoice by changing the module, field names, and other parameters.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Click the Deals module and select the required list view.
- Select the deal record for which you want to create a new quote.
- Click the button you added to the details page in the top-right area. For example, Create quote with products.
- Check whether the quote is pre-populated with the products linked to the deal record.
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 PointCustom Button
- EditionEnterprise and above
- ComplexityMedium
- Implementation Time30 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST