Display discount in words

Business scenario:

Offering discounts is one of the common approaches taken by most companies to clock more sales. It's a proven strategy to win more new customers and retain the existing ones. From a business operations perspective, discounts help you get rid of your old inventory. This is immensely beneficial in the long run.

It is very important to document the discounts provided within the CRM records Say, the same customer purchases from you after a long hiatus. Your negotiating agent must be aware of the previous deals made with the customer, including the amount of discount given earlier.

Usually, discounts are specified in percentage. Like 5% discount. There is a percentage field in Zoho CRM, which you can name as "Discount" and enter the value as 5 (Only for custom modules. Native Deals module already has a discount field). Some of our customers prefer the discount to be tracked on a text field in words. For example, "Discount of 5%" instead of just 5% in the percentage/discount field. This week's custom function helps you do just that.

 

Getting started with the function:

  1. Go to Setup > Developer Space > Functions > + Create New Function.
  2. Select Automation as Function type and click Next.
  3. Provide a name for the function. Add a description(optional).
  4. Copy the code given below.
  5. Click Edit Arguments.
  6. Enter the name as customId and select the type as Int.
  7. Click Save&Execute Script.
  8. Click Save.
 

The Code:


customDetails = zoho.crm.getRecordById("moduleapiname", customId.toLong());
//info customDetails;
percent = ifnull(customDetails.get("Discount"),"");
if( percent == "")
{
mp=map();
mp.put("Wording","");
update = zoho.crm.update("moduleapiname", input.customId.toLong(), mp);
info mp;
info update;
}
else
{
mp=map();
mp.put("Wording","Discount : "+input.percent + "%");
update = zoho.crm.update("moduleapiname", input.customId.toLong(), mp);
info mp;
info update;
}

 

Change 'moduleapiname' with that module's api name. Also the field "Wording" is a custom field. You can name it any way you want.

 

Note:

  • The above code works only for API V2.0 and not the previous version.
 

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips