Function-1: Compute and update sales commission in quotes.

Function-1: Compute and update sales commission in quotes.

 

Welcome back folks!

In this week's custom functions series, we've picked a requirement that has often been asked by users!


Business requirement:

In most sales organizations, commissions are an integral part of the extrinsic rewards program, contributing significantly to the sales person’s compensation package. Sales commission is usually calculated as a percentage of revenue generated by the sales person. What if your sales team is enabled with an option to check their sales commission associated with each quote? The first post in 'Automate using Custom Functions' series unravels just that.


A sample scenario:

Let's  assume a case where a sales person gets a commission based on the quantity of products she/he sells. I'm sure you agree that this is  an important practice in many  companies. Internally, there must be records to know just how much commission the sales person received.  Zoho CRM tracks the commission associated with the sale of each product in ‘Commission Rate’, a standard field in the Products module. Using custom functions, this information is pushed to the Quotes module. The commission associated with each line item of the quote is calculated and summed up to find the overall commission associated with that quote.The resultant value is then updated in a custom field in the Quotes module. Pretty convenient right?



Steps to add a custom function:

  1. Click  Setup > Actions under Automation > Custom Functions > Configure Custom Function > Write your own .
  2. Enter the name of the Custom function. For example: “Calculate commission in Quotes”.
  3. Select the module as  Quotes . You can add a description as well(optional).
  4. Click “ Free flow scripting ”.
  5. Copy the code given below.
  6. Click “ Edit arguments ”.
  7. Enter the name as “ quoteId ” and select the value as “ Quote Id ”.
  8. Click  Save .
 

The script:


Code for Version 2.0 API:

 

quoteMap = zoho.crm.getRecordById("Quotes", input.quoteId.toLong()); 

productDet = ifnull(quoteMap.get("Product_Details"),""); 

value = 0.0; 

for each eachProd in productDet 

{ 

qty = (ifnull(eachProd.get("quantity"),"0")).toLong(); 

productId = ifnull(eachProd.get("product"),"").get("id"); 

proDetails = zoho.crm.getRecordById("Products", productId.toLong()); 

commission = (ifnull(proDetails.get("Commission_Rate"),"0.0")).toDecimal(); 

value = (value + commission * qty); 

} 

params = map(); 

params.put("Total_Commission", value); 

updateResp = zoho.crm.update("Quotes", quoteId.toLong(), params); 

info params;

info updateResp;

——————————————————————————————————————————
Code for Version 1.0 API:

quoteIdStr = input.quoteId.toString();
quoteMap = zoho.crm.getRecordById("Quotes", input.quoteId);
productDet = ifnull(quoteMap.get("product"),"");
productList = productDet.toJSONList();
value = 0.0;
for each eachProd in productList
{
eachProdDet = eachProd.toMap();
qty = (ifnull(eachProdDet.get("Quantity"),"0")).toLong();
productId = ifnull(eachProdDet.get("Product Id"),"");
proDetails = zoho.crm.getRecordById("Products", productId.toLong());
commission = (ifnull(proDetails.get("Commission Rate"),"0.0")).toDecimal();
value = (value + commission * qty);
}
params = map();
params.put("Total Commission", value);
updateResp = zoho.crm.updateRecord("Quotes", quoteIdStr, params);

——————————————————————————————————————————


Note:

  • Change the "[field Id]" or "[module]" name to any other module or field name(Custom modules or fields) to fit your requirement.
  • Update the commission associated with each product in the Products module.
  • Create a custom field in Quotes module where the commission associated with the quote gets updated.

Do try this out and let me know how it worked. If you have questions, ask away. Share this with your team if you think they'll find this useful. See you all next week with another interesting custom function in this series. Until then!


Update: As you must be aware, API V1.0 will be deprecated and support for version 1.0 API will be available only till Dec 31, 2018. Version 1.0 compatible Functions will continue to work until Dec 31, 2019. You're advised to migrated to API Version 2.0 at the earliest. Check this announcement for more. We've updated the post to include the Version 2.0 compatible Function.

    Access your files securely from anywhere



                      Zoho Developer Community




                                              • Desk Community Learning Series


                                              • Digest


                                              • Functions


                                              • Meetups


                                              • Kbase


                                              • Resources


                                              • Glossary


                                              • Desk Marketplace


                                              • MVP Corner


                                              • Word of the Day


                                              • Ask the Experts



                                                        • Sticky Posts

                                                        • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

                                                          Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
                                                        • User Tips: Auto-Create Opportunity/Deal upon Quote Save (PART 1)

                                                          Problem: We use quotes which convert to sales orders but Users / Sales Reps do not create opportunities / deals and go straight to creating a quote. This leads to poor reporting. Implementing this solution improves reporting and makes it easier for users.
                                                        • Custom Function : Automatically send the Quote to the related contact

                                                          Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
                                                        • Function #50: Schedule Calls to records

                                                          Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM
                                                        • Function #37: Create a Purchase Order from a Quote

                                                          Welcome back everyone! Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote. Business scenario: In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order,


                                                        Manage your brands on social media



                                                              Zoho TeamInbox Resources



                                                                  Zoho CRM Plus Resources

                                                                    Zoho Books Resources


                                                                      Zoho Subscriptions Resources

                                                                        Zoho Projects Resources


                                                                          Zoho Sprints Resources


                                                                            Qntrl Resources


                                                                              Zoho Creator Resources



                                                                                  Zoho CRM Resources

                                                                                  • CRM Community Learning Series

                                                                                    CRM Community Learning Series


                                                                                  • Kaizen

                                                                                    Kaizen

                                                                                  • Functions

                                                                                    Functions

                                                                                  • Meetups

                                                                                    Meetups

                                                                                  • Kbase

                                                                                    Kbase

                                                                                  • Resources

                                                                                    Resources

                                                                                  • Digest

                                                                                    Digest

                                                                                  • CRM Marketplace

                                                                                    CRM Marketplace

                                                                                  • MVP Corner

                                                                                    MVP Corner





                                                                                      Design. Discuss. Deliver.

                                                                                      Create visually engaging stories with Zoho Show.

                                                                                      Get Started Now


                                                                                        Zoho Show Resources


                                                                                          Zoho Writer Writer

                                                                                          Get Started. Write Away!

                                                                                          Writer is a powerful online word processor, designed for collaborative work.

                                                                                            Zoho CRM コンテンツ








                                                                                              Nederlandse Hulpbronnen


                                                                                                  ご検討中の方




                                                                                                        • Recent Topics

                                                                                                        • Email signature duplicate

                                                                                                          Hi, For a few weeks, opening the email writer would show an error. After clicking ok, the signature would change slighty (font size, I believe). After that it worked fine, so we thought nothing of it. However, now it no longer shows the error puts the
                                                                                                        • emails to AOL / Yahoo bouncing

                                                                                                          When I send email to an AOL account this morning, I receive the following error: -------------------------------------------------------------------------------------------------------------------------------------------------- This message was created
                                                                                                        • New Agent Creation - Not Receiving Activation Email

                                                                                                          I created multiple new agents within Zoho Desk with no issue. Everyone one of them received the activation email except one. The email is correct and confirmed multiple times. It is not located in the Spam folder. I withdrew the activation and recreated
                                                                                                        • Can I access the root directory?

                                                                                                          I would like to add push notifications to my site and I need to add the code to the root directory.
                                                                                                        • Templates when adding a ticket

                                                                                                          Hello, When adding a ticket and crafting a description is it possible to have the templates available? I would like to do it all at once vs creating the ticket then navigating to the ticket to send the initial contact. Thank you,
                                                                                                        • Facing issue in getting data through api calls

                                                                                                          I have send data of users and want to get the data oof users but facing issue with one field for that I want help
                                                                                                        • invokeURL to change custom field

                                                                                                          I have a deluge script that currently runs as a Schedule. It works exactly as intended, however I've recently been informed by Zoho that there's some mechanism in place to block changes made by a script when it runs on a schedule from being detected by
                                                                                                        • How to stop workflow running twice on a record

                                                                                                          Hi I have a workflow as below Trigger: Lead record is created/edited - Repeat this workflow whenever a lead is edited is NOT TICKED Condition: When Lead Stage is MQL Action: Reassign Lead, Create Task If the Lead goes into stage MQL, and then it changes
                                                                                                        • Retrieving a sandbox

                                                                                                          Is there a way to retrieve a previous sandbox build?
                                                                                                        • Calculate your investment's value with the NPV, PV, and FV functions in Zoho Office Integrator

                                                                                                          Hi users, We are pleased to introduce three new formulas in Zoho Office Integrator's document editor: Net Present Value (NPV), Present Value (PV), and Future Value (FV). These formulas allow you to calculate the value of your investment over a specific
                                                                                                        • Best Way to Integrate a Shared Sales Inbox with Zoho CRM

                                                                                                          I’m setting up a shared email inbox (e.g., sales@mycompany.com) for our sales team and want to integrate it with Zoho CRM Leads and Deals so that multiple team members can collaborate efficiently. Since Zoho CRM doesn’t support IMAP for shared inboxes,
                                                                                                        • Last name is being added into first name

                                                                                                          We have noticed in our campaigns that the last name is being included with the first name for some people. We have gone through the CRM and they are all entered correctly. Does any one have any ideas how why and how to fix this?
                                                                                                        • Kiosk Page Refresh

                                                                                                          We have a Kiosk running from a button in contacts to update values and also add related lists, which works great, but when the kiosk is finished the page does not refresh to show the changes. Is there a way to force the contact to refresh/update when
                                                                                                        • Sending User-centric reports to all users

                                                                                                          I would like to automate an e-mail report to all users that sends them a weekly e-mail listing their open Potentials.  I've created a Report that uses the ${CURRENTUSER} criterion and scheduled the report to send to several users, but they all receive
                                                                                                        • Let's build a dashboard with Cliq Widgets!

                                                                                                          While juggling multiple tasks and tracking real-time data, you face a strict deadline for delivering a quarterly analysis report on a blank canvas while switching between different apps. Sounds exhausting, right? What if you could streamline everything
                                                                                                        • Merge Join PDFs Zoho Creator

                                                                                                          Hi all, I have a field where users upload PDF, is it possible to join those pdfs into one with a function or something? Regards.
                                                                                                        • It's time to say goodbye to Zoho Recruit for me.

                                                                                                          Hello, I have been a Zoho Recruit user since 2013. The tool has evolved, with a better UI, new features and so on. The pricing is still a great asset too. BUT, that being said, important features are not coming fast enough. I tried to share my point of
                                                                                                        • how to send recurring estimates instead of recurring invoices

                                                                                                          Hello, Is it possible to use the recurring invoice functionality to send recurring estimate to our customers ? We first need to send them an invoice in order to receive their purchase order and then send them the invoice with their purchase order number
                                                                                                        • View Reference Values in pick list field not showing

                                                                                                          Dears, I want to create a custom field, type "Pick List", to define the language of a Lead. I want a pick list with some options value ("en", "fr", "de", etc.) and I want to display this options with a reference ("English" for "en", "Français" for "fr",
                                                                                                        • Quais são os maiores desafios que você enfrenta ao implementar o Zoho CRM?

                                                                                                          Olá, pessoal da comunidade Zoho Brasil! Sou parceiro autorizado da Zoho e, ao longo do tempo, tenho notado que cada implementação de CRM traz desafios únicos, dependendo do segmento de negócio, das metas da empresa e até da familiaridade da equipe com
                                                                                                        • How to download Renamed File that already updated to Zoho Creator.

                                                                                                          Hi members, I construct a button with report workflow. link = "https://creatorexport.zoho.com" + zoho.appuri + "report_link_name/File_upload/image-download/" + input.File_upload; openUrl(link,"new window"); This script able to download the file. But I
                                                                                                        • [ Free Webinar] Transform your hiring process with Zoho Recruit's AI tools

                                                                                                          We are conducting a free webinar (on 26th November, 05:00 AM IST - 06:00 AM IST) designed to help you make the most of Zoho Recruit’s AI capabilities and give you a sneak peek into our future roadmap. Why Attend? In this session, you will: Discover how
                                                                                                        • Zoho invoice doesn't support Arabic language

                                                                                                          I added a clause in the terms & conditions section in Arabic but it doesn't appear when I sent or print it.
                                                                                                        • Introducing Assessment-based Filters in Zoho Recruit

                                                                                                          We're thrilled to announce a handy new feature: Filtering Candidates by Assessment Answers. This tool allows you to refine your candidate search based on their performance in screening tests or assessments. It's a great way to find candidates who meet
                                                                                                        • Reports - Billable Hours

                                                                                                          Hello, I have been playing around with some of the reports features but haven't yet been able to generate a report outlining Tickets which have been closed, that have billable time entries - defined against customer accounts - I can run a report showing
                                                                                                        • 📣📣 Zoho Bookings - Feature Roadmap 2024

                                                                                                          Hi Everyone, Thank you for all the support you have been showing Zoho Bookings. We had a fabulous 2023, with a bunch of new features and over 60K new users. In 2024, our prime focus will be on user experience, and we have a few vital features coming in
                                                                                                        • Couldn't connect to host, port: wordpress2224249.home.pl, 143; timeout 10000

                                                                                                          Hey, i get a error up "Couldn't connect to host, port: wordpress2224249.home.pl, 143; timeout 10000" But i tried same passwords and info. to make imap on hotmail. and it works flawlessly. Has to be something with zoho....
                                                                                                        • Using lookup field in Formula field

                                                                                                          I created the following formula field to get string output based on Lookup field values Lead and Account: if(${Communications.Lead}!='','Lead',if(${Communications.Account}!='','Account','Other')) The syntax seems correct, but I'm still getting an error.
                                                                                                        • Customize the ticket ID for enhanced ticket tracking

                                                                                                          Hello everyone, Ticket IDs in Zoho Desk are the unique reference numbers that are assigned to tickets when they're created. Agents generally use the ticket ID to locate a particular ticket and to reference a ticket in conversations and feeds. When customers
                                                                                                        • Set a global default filter to All Candidates view

                                                                                                          Hi, Is it possible to set a global filter to the All Candidates view? As a use case would be for off-limit candidates. These are those who are off limits due to previous bad client feedback on performance/behaviour. Ideal use case would be to set these
                                                                                                        • Can't join canal Developers Zoho User

                                                                                                          Hello, I received an invitation to join this channel, but I get an error when I try to join it, and I get the same error when I go to the Zoho Cliq interface > Search for a channel. Is this because I don't have a license linked to this email address?
                                                                                                        • Searching for content within courses

                                                                                                          Hello, I have been testing out Zoho One for my company have been exploring Learn. I've noticed that you cannot search for content within a course. You can only locate the title of the course. Example: Course: How to Make Your Bed Chapter: Pillows Lesson:
                                                                                                        • Remove "Additional Information" options from user-created tickets

                                                                                                          I'd like to configure customers to be able to create tickets themselves, with and without logging in. However, I don't want them to set things like the priority or due date. Is there a way to remove these options from the help center when customers create
                                                                                                        • Issue Loading Dynamic Table Fields in Zoho Writer

                                                                                                          I am experiencing an issue while configuring a repeat table in Zoho Writer. When attempting to insert a dynamic table, I receive the following error: "There was a problem loading your dynamic table fields. Please try again in a while." I have already
                                                                                                        • FSM Function not executing

                                                                                                          Good Afternoon, all I am working on a workflow function in FSM and yesterday it was working fine. Now today when I select "Save & Execute" it does nothing. I even tested it with just a info statement and it is not executing. Any help would be greatly
                                                                                                        • Announcing Early Access to "Zoho CRM for Everyone" — A new and exciting update to Zoho CRM

                                                                                                          We are delighted to announce an Early Access to Zoho CRM for Everyone— a truly democratic approach to managing a CRM, gift-wrapped in an exciting and intuitive user interface. Here, multiple teams across an organization can coordinate among each other
                                                                                                        • API - Inactive user

                                                                                                          Hi We have a complex flow set up with an API. Yesterday I needed to inactivate a user who had set up the flow and API- realised after this, then broke the connection so - re-activated the user. The flow now seems not to work when gaining information from
                                                                                                        • Based onthe multipick list value want to Show in the pick list field

                                                                                                          Based onthe multipick list value want to Show in the Single pick list field Database Region is multipick list if it contain Saudi and UAE then region pick list want to show Saudi and UAE Database Region is multipick list if it contain Saudi then region
                                                                                                        • CRM quotes and sub forms.

                                                                                                          Recently upgraded to Enterprise CRM - now some added hopes/questions * In a subform in quotes, if I add a "Percent" field, called Overage for instance. I would expect it to allow me to enter a percent like "10%" and carry the percent forward to formulas
                                                                                                        • Add Mileage Tab on Expenses

                                                                                                          Hello, the 'Add Mileage' tab is not visible. How can I enable it? I checked the settings, and my user has admin privileges. I also enabled mileage in the policy, but the 'Add Mileage' tab is still not visible. What could be the issue?
                                                                                                        • Next Page