View all related quotes in a product

Retrieve all quotes that include a specific product and display them on their details page.

Creating and sharing sales quotes with customers is a key function of sales teams in CRM. These quotes include products or services your business offers, which have been added to their quoted items section. They provide customers and the sales team with information about which products/services are offered to customers, before a sale is completed.

However, once a product is added to a sales quote, no direct or visible association is recorded in the product itself, indicating which quotes contain that product. This lack of visibility makes it difficult for your sales team to track the quoting history of each product and identify demand trends, both of which are essential for informed selling and strategic decision-making.

Wouldn't it be beneficial for your salespeople to view all quotes that include a specific product directly from the product details page? Well, we have you covered. You can achieve this using a low-code custom function that retrieves all quotes related to a specific product and displays them in its related list section. Read on to learn more.

Permissions and availability

  • Users with the Manage Extensibility permission can create connections and write custom functions.
  • Users with the Modules Customization permission can add related lists to a module.
  • Users with the Manage Sandbox permission can manage the sandbox.

Requirements

  • Create a Zoho OAuth connection with the required scopes for your Zoho CRM, as detailed in the "Create Connection" section below. Learn more
  • Write a custom function using Zoho's Deluge scripting language that fetches all quotes that include a specific product. Learn more
  • Add a related list within the product details page and include the custom function to display the related quotes. Learn more
  • Test the function in a sandbox environment before deploying it to your production environment. Learn more

Create a connection

The first step is to create an OAuth connection in your Zoho CRM account.

  1. Navigate to Setup > Developer Hub > Connections.
  2. Click Create Connection.
  3. Select Zoho OAuth under Default Services.
  4. Specify a Connection Name.
    You will enter this name in the code snippet below.
  5. Select the following Scopes to request access.
    • ZohoCRM.modules.ALL
    • ZohoCRM.coql.READ
  6. Click Create and Connect.
  7. Click Connect, then click Accept to confirm authorization of access for the scopes requested by the client.

Write a custom function

The next step is to write the custom function that will be linked to the related list.

  1. Go to Setup > Developer Space > Functions > +New Function.
  2. Provide a name and display name for the function. For example: "View Related Quotes".
  3. Select the category of the function as Related List.
  4. Copy and paste the code provided below.
  5. Click Edit Arguments.
  6. Enter the parameter name as id, select the type as string, and click Save.
  7. Click Save on the function page.

The code

Code Copied
queryMap = Map();
queryMap.put("select_query","SELECT Parent_Id,Parent_Id.Subject, Parent_Id.Grand_Total,Parent_Id.Quote_Stage FROM Quoted_Items WHERE Product_Name.id =" + id + " ");
response = invokeurl
[
	url :"https://www.zohoapis.com/crm/v5/coql"
	type :POST
	parameters:queryMap.toString()
	connection:"connectionname"
];
info "response->" + response;
dt = response.get("data");
i = 1;
if(dt == "")
{
	errormsg = "No records are found";
	msg = "<error><message>" + errormsg + "</message></error>";
}
else
{
	d = "<record>";
	count = 0;
	for each  ele in dt
	{
		sub = ele.get("Parent_Id.Subject");
		total = ele.get("Parent_Id.Grand_Total");
		stage = ele.get("Parent_Id.Quote_Stage");
		did = ele.get("Parent_Id").get("id");
		urllink = "https://crm.zoho.com/crm/org167693575/tab/Quotes/" + did;
		d = d + "<row no=\"" + i + "\">";
		d = d + "<FL val=\"Record No.\">" + i + "</FL>";
		d = d + "<FL link=\"true\" url=\"" + urllink + "\" val=\"Subject\">" + sub + "</FL>";
		d = d + "<FL val=\"Grand total\">" + total + "</FL>";
		d = d + "<FL val=\"Quote Stage\">" + stage + "</FL>";
		count = count + 1;
		i = i + 1;
		d = d + "</row>";
	}
	d = d + "</record>";
	if(count == 0)
	{
		errormsg = "No quotes are associated";
		msg = "<error><message>" + errormsg + "</message></error>";
	}
	else
	{
		msg = d;
	}
}
info msg; 
return "Success";

Notes

  • Replace "connectionname" with the name of the connection you specified while creating it in your CRM (see the Create a connection section above).
  • Make sure to use the accurate API names for their corresponding fields in the code snippet. Learn more
  • You won't be able to add new quotes or modify the displayed quote fields on the new related list.

Add a related list

The final step is to add a related list to the product details page to display their related quotes.

  1. Open a product record to view its details.
  2. Go to the Related List panel on the left and click the Add Related List option.
  3. Select Functions in the pop-up window.
  4. Select Add Now, corresponding to the function you created in the previous steps.
  5. Specify a name for the related list. For example: "Related Quotes".
  6. Press # to fetch the merge field and map the argument as id = Products > Product Id.
  7. Click Save.

Tips

  • Click the Reorder icon to move Related Quotes to a specific location on the Product Details page.
  • Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.

Test the solution

  1. Go to the Products module and click on the desired product.
  2. On the Product Details page, look for the Related Quotes related list section. It will display all the quotes created for the product.
  3. Create new quotes containing the product and check whether they are displayed in the related list.

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

  • ModuleProducts
  • Trigger PointRelated List
  • EditionEnterprise and above
  • ComplexityMedium
  • Implementation Time30 minutes

Features used in the solution

ConnectionDeluge ScriptRelated ListSandbox
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!