Function-6: Sum up multiple quotes grand total associated to a deal.

Function-6: Sum up multiple quotes grand total associated to a deal.


Welcome back everyone!

Last week, we learnt how to - create quotes from deals with just the click of a button. This week, let's look at a custom function that sums up total value across the quotes linked to a specific deal.

Business scenario:

Assume you created a deal pertaining to a particular product category that your organization is engaged. This deal is linked with all the related quote records across customers. Or another deal related to all businesses done in the current fiscal year with a particular customer, and linked all the related quote records. While most businesses follow convention, that is - qualify a lead, create an account and a contact, link it to a deal, create a quote and such. However, there are some of us who jump these conventions, right? :) Zoho CRM offers you the flexibility of such customizations to fit your business requirements. Customizations with the added ability of automation lets you sum up all the quote values related to a deal.

Besides, you can use it for other modules as well by simply changing the module name in the code accordingly.

Getting started with the custom function:

For the Quote module:

  • Go to Setup > Automations > Actions > Custom Functions > Configure Custom Function > Write your own.
  • Provide a name for the custom function. For example: “Sum up deals as a field - 1”. Add a description(optional).
  • Select the module as Quotes. Add a description(optional).
  • Click “Free flow scripting”.
  • Copy the code given below.
  • Click “Edit arguments”.
  • Enter the name as “potId” and select the value as “Potential Id”.
  • Save the changes.

For the Deals module:

  • Go to Setup > Automations > Actions > Custom Functions > Configure Custom Function > Write your own.
  • Provide a name for the custom function. For example: “Sum up deals as a field - 1”. Add a description(optional).
  • Select the module as Deals. Add a description(optional).
  • Click “Free flow scripting”.
  • Copy the code given below.
  • Click “Edit arguments”.
  • Enter the name as “potId” and select the value as “Potential Id”.
  • Save the changes.

Note:
The name of the module "Deals" should be mentioned as "Potentials" in the code, no need to change that name to Deals .

The Script:

For the Quotes Module:
Code for Version 2.0 API:

RelatedQuotes = zoho.crm.getRelatedRecords("Quotes", "Deals", potId.toLong(),1,200);
//info RelatedQuotes;
total = 0.0;
for each ele in RelatedQuotes
{
grand =ifnull(ele.get("Grand_Total"),"0.0").toDecimal();
total = (total + grand);
}
mp = map();
mp.put("Amount", total);
update = zoho.crm.update("Deals", potId.toLong(), mp);
info mp;
info update;

Code for Version 1.0 API:

potIdStr = input.potId.toString();
RelatedQuotes = zoho.crm.getRelatedRecords("Quotes", "Potentials", potIdStr);
info RelatedQuotes;
total = 0.0;
for each ele in RelatedQuotes
{
grand =ifnull(ele.get("Grand Total"),"0.0").toDecimal();
total = (total + grand);
}
mp = map();
mp.put("Amount", total);
update = zoho.crm.updateRecord("Potentials", potIdStr, mp);
info mp;
info update;
For the Deals Module:
Code for Version 2.0 API:

RelatedQuotes = zoho.crm.getRelatedRecords("Quotes", "Deals", potId.toLong(),1,200);
//info RelatedQuotes;
total = 0.0;
for each ele in RelatedQuotes
{
grand =ifnull(ele.get("Grand_Total"),"0.0").toDecimal();
total = (total + grand);
}
mp = map();
mp.put("Amount", total);
update = zoho.crm.update("Deals", potId.toLong(), mp);
info mp;
info update;

Code for Version 1.0 API:

potIdStr = input.potId.toString();
RelatedQuotes = zoho.crm.getRelatedRecords("Quotes", "Potentials", potIdStr);
info RelatedQuotes;
total = 0.0;
for each ele in RelatedQuotes
{
grand =ifnull(ele.get("Grand Total"),"0.0").toDecimal();
total = (total + grand);
}
mp = map();
mp.put("Amount", total);
update = zoho.crm.updateRecord("Potentials", potIdStr, mp);
info mp;
info update;






Found this useful? Try it out and let me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful. See you all next week with another interesting custom function. Ciao!

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




                                      Zoho Desk Resources

                                      • Desk Community Learning Series


                                      • Digest


                                      • Functions


                                      • Meetups


                                      • Kbase


                                      • Resources


                                      • Glossary


                                      • Desk Marketplace


                                      • MVP Corner


                                      • Word of the Day



                                          Zoho Marketing Automation
                                                  • 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
                                                  • 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,
                                                  • Function-2: Round-Robin assignment of records

                                                    Welcome back folks! Last week, we saw how to update sales commission in quotes using a custom function. This week, let's see an interesting use case asked by many of you - auto-assignment records by round-robin method. Business scenario: Right now, the solution allows you to auto-assign leads from web form and imported lists. Let us look at a need where you want to auto-assign leads from in-bound calls in a round-robin method, across modules. Prerequisite: You must create a permanent record in the


                                                  Manage your brands on social media



                                                        Zoho TeamInbox Resources

                                                          Zoho DataPrep 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

                                                                                                  • Can you modify "Last Activity Time" in deluge? If so what's the field name?

                                                                                                    I need to perform some bulk modifications on records in the Leads module, but I need to avoid changing the "last activity time" or "date modified" because I am using those fields to filter and sort leads for follow-up action. I cannot find an answer anywhere
                                                                                                  • How do I define a weekend

                                                                                                    I noticed the default for weekends does not seem to include Saturdays. How can i define weekends to include both Saturdays and Sundays? Thank you.
                                                                                                  • 【Zoho CRM】ポータル機能のアップデート

                                                                                                    ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 今回は「Zoho CRM アップデート情報」の中からポータル機能のアップデートをご紹介します。 今回の機能アップデートにより、CRMのポータルへのログインがより簡単にできるようになりました。 【目次】 SAMLベースのシングルサインオンについて ポータルへのアクセスリンク送付について 今回のアップデートにより、アイデンティティプロバイダー(IdP)を利用している組織において、SAMLベースのSSO(シングルサインオン)を有効化できるようになりました!
                                                                                                  • Getting error during inserting a record in form of zoho people using zoho api

                                                                                                    import requests import json # Set your access token and Zoho People API base URL access_token = '1000.XXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXX' api_base_url = 'https://people.zoho.in/people/api/' # Set the form name and data to be inserted form_link_name
                                                                                                  • UI Arabic

                                                                                                    can i change the member portal UI to arabic in zoho community?
                                                                                                  • Resume template to include profile photo

                                                                                                    Hi, We would love the Resume Template to be able to include their profile photo. How can this be done? Miriam
                                                                                                  • Marking a form as 'done'?

                                                                                                    Hi! I've got a form that staff fill in when moving stock from location to location. I see the entries they've sent across and I input them into my stock control system. Is there a way to mark a form as 'done'? So that I know which entries I've input,
                                                                                                  • Zoho CRM - best way to search an account and assign to a deal

                                                                                                    Hi Everyone I am looking for some advice. I want to find the best way to complete the below steps. We have a deal and once it reaches a certain stage we need to allocate a supplier / vendor to this deal along with the salesperson. I want to add (ideally
                                                                                                  • How to easy change layout in existing records in Deals?

                                                                                                    Hello, So far i have used only 1 layout in Deals. I have about 1000 records. Now i want to make new layout. So i have 2 layouts: Layout Old (1000 records) Layout New (0 records) How to easy change layout from Layout Old into Layout New for existing records?
                                                                                                  • Zoho Rating

                                                                                                    When I close a ticket, the zoho system automatically sends an email to the customer for them to leave a rating. When they leave a rating, the ticket re-opens and I have to close it again. When I close it again, the zoho system sends the customer an email
                                                                                                  • Zoho GC Flow is not showing in IM Channels

                                                                                                    I have added my social IM channels in zoho desk. Created a GC Flow to automate conversations. But Guided conversations are not showing in any platforms I have chosen; WhatsApp Instagram Messenger Web (Business Messaging) In the flow I mentioned these
                                                                                                  • Sharing Knowledge Base articles across multiple departments

                                                                                                    It would be useful to share some Knowledge Base articles across multiple departments where they are applicable, rather than having to go into other departments to find the article you're looking for. For example. Our reception uses the 'Admin' desk whereas our IT guys use the 'Support' desk, however both divisions would find KB articles about our company intranet useful. Reception does not have access to the support desk, so cannot see articles created in the Support KB. Perhaps you could install
                                                                                                  • Contacts marked as Spam are shown as Contacts in tickets.

                                                                                                    Hi Zoho, If a ticket is marked manually as Spam you get an option to set the contact as Spam as well. It would be great if there was another option to delete this Contact. This would be based on the understanding that it wouldn't be marked automatically
                                                                                                  • Is possible to use ${webhookTrigger.payload.street==null?"No street":${webhookTrigger.payload.street}} for to detect inline a null parameter

                                                                                                    Hi Team I need to know if it's possible to evaluate inline the following parameter, with the objetive to detect a null value ? I would like to use ${webhookTrigger.payload.street==null?"No street":${webhookTrigger.payload.street}} Regards, Pablo
                                                                                                  • Real Estate CRM

                                                                                                    How can I tailor my CRM for real estate? I had seen an image where the CRM included property tabs.
                                                                                                  • Issue with Bulk Edit Triggering Function Multiple Times in Zoho Report

                                                                                                    In our Zoho report, we have observed an issue where executing a function during a bulk edit operation runs the function multiple times—once for each selected report entry. This behavior is causing errors due to overlapping or redundant executions. Our
                                                                                                  • Is there a Kanban view of Tasks across all Projects?

                                                                                                    As the title indicates, I could use a Kanban view of my Tasks across my Projects. If it's there, I don't see it. If it isn't there, I'd like to submit this as a feature request. Thx.
                                                                                                  • Set recurring tasks in Zoho Support?

                                                                                                    Hello,   We use the task function in Zoho Support to set reminders for "due dates" of important events, such as lease expirations, etc. Is it possible to set some of these as recurring yearly? As of now, we have to reset every task manually after one year. Is there a way to have it reset automatically?   Additionally, is there a way to import a list of tasks and their dates into Zoho Calendar? I have not been able to do it from Zoho Support to Calendar. I tried exporting tasks from Zoho Support,
                                                                                                  • Help - How Can I Enter a Hourly Rate (Global Cost) for our Team for Profitability Reporting?

                                                                                                    Hi everyone, I'm hoping someone can help as I am at a loss and am quite shocked (if true) at the lack of functionality in Zoho Books. We run a company in which we do hourly jobs for clients and we bill based on the hours of work completed. Projects are
                                                                                                  • Schedule a regular backup

                                                                                                    In CRM I have a regular backup setup. I cannot find an option to backup Desk? I would like to take a backup before I test syncing products between CMR and Desk.
                                                                                                  • Limit who can submit a support ticket to your site?

                                                                                                    Does anyone have a use case for needing to limit who can submit tickets via your help portal? Some of our customers want to have end-users view our knowledge base articles and see tickets their IT groups have submitted but they do not want end-users to
                                                                                                  • Is there a way to request a password?

                                                                                                    We add customers info into the vaults and I wanted to see if we could do some sort of "file request" like how dropbox offers with files. It would be awesome if a customer could go to a link and input a "title, username, password, url" all securely and it then shows up in our team vault or something. Not sure if that is safe, but it's the best I can think of to be semi scalable and obviously better than sending emails. I am open to another idea, just thought this would be a great feature.  Thanks,
                                                                                                  • Allow us to disable the Reopen Ticket button after a ticket is closed

                                                                                                    Disabling the Reopen Ticket will allow us to have more control over the ticket's flow. According to support, this is currently not possible. Please add this to let us, the customers, mold the ticketing system into something that we can use for our business
                                                                                                  • How to Enforce Mandatory Fields (Category/Sub-category) Before Closing a Ticket?

                                                                                                    Hi, I'm currently using Zoho Desk and encountering an issue where agents are able to close tickets without filling out mandatory fields, specifically Category and Sub-category. I’ve already set them both as a mandatory field, but it can still be bypassed
                                                                                                  • Admin Control for Default Email Templates in Zoho Desk

                                                                                                    Hi Zoho Desk Team, We would like to request a feature enhancement related to default email templates. Currently, agents can select and set their own default email templates when replying to tickets. However, we believe this setting should be managed centrally
                                                                                                  • Lock out of account after password update

                                                                                                    This is a bit of a catch 22 situation. I updated my account password using password generator in ZohoValut. Now I am locked out of everything, as I cannot get into OneAuth for 2FA, as the password is randomly generated, without getting into ZohoValut,
                                                                                                  • Guidance on Making Zoho Desk Connections Available for All Data Centers

                                                                                                    Hi Team, I’m currently developing an application using Zoho Desk connections to manage OAuth for my third-party products. Could you please advise on the steps required to make it available across all data centers? Looking forward to your thoughts on
                                                                                                  • Multibrand Help Center - Share knowledge base catgories between multiple departments

                                                                                                    Hello, I would like to know if it is possible to share categories between multiple departments when the multi brand feature is enabled. So that then one portal exists per department, but certain categories are visible in multiple portals. After all, we
                                                                                                  • Unable to upload document error on zoho sign

                                                                                                    i am creating a document using laravel php and here is my code and i get this reponse {"code":2005,"message":"Unable to upload the document","status":"failure"} $path = storage_path($file); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://sign.zoho.com/api/v1/requests');
                                                                                                  • Cloud to cloud folder migration from Sharepoint to Workdrive

                                                                                                    I am aware of OneDrive migration: https://help.zoho.com/portal/en/kb/workdrive/migrations/microsoft/articles/migrate-from-onedrive-to-zoho-workdrive#Whats_migrated would this cover a Sharepoint migration meaning I can move a whole Sharepoint (team) folder
                                                                                                  • Zoho Sign / Prefill By You - Editable by Them!

                                                                                                    Zoho Sign seems to have two field options available - an empty field for signer(s) to complete or a field that has been prefilled by you, that becomes read only once sent.  What I would like is an option on the pre-filled by you fields, to leave them
                                                                                                  • How to sort a data in summary report with Monthly ?

                                                                                                    Hi Team, Can any one help me out how to sort a data based on monthly, Month was shuffled based on aliphatic order. i want to sort the below data monthy?
                                                                                                  • Kiosk Studio wrap-up | How our community used kiosks in 2024

                                                                                                    Hello, everyone! Happy new year! The end of 2024 has been busy, and 2025 promises to be bigger and better. As we ring in the new year, let's rewind and look at Kiosk Studio, our no-code customization tool. The past 300 days have seen the CRM community
                                                                                                  • Zoho Crm - Inventory Integration

                                                                                                    Hello, I need help about Map Fields between CRM and Inventory. For Example, I can't match amount of stock between these 2. I can put opening stock number  in Inventory but I can't see it on CRM. Also I want to see categories and parent categories on Inventory, in CRM too. Best Regards.
                                                                                                  • Inventory Valuation Method Feature

                                                                                                    Zoho added another feature so called Inventory Valuation Method of each Item. This is actually good to see and it will benefit us so much but I have a question on this. For Existing Items that already have transactions, Zoho made it a default and assumed
                                                                                                  • Where is the customization and extendibility of zoho inventory?

                                                                                                    After delving into zoho one subscription to test out systems we need for our business, I'm really disappointed after working in Zoho Inventory. Its features and customizability are extremely lacking compared to the other tools like CRM. In our case we
                                                                                                  • Organization Variables - Restrict Access

                                                                                                    Currently, there is no way to restrict the access to organization variables. This leads to a problem when storing API related values that should be kept secret as anyone with access to create and edit email templates, workflow rules, or inventory templates
                                                                                                  • Zoho takes too long to load...

                                                                                                    I am based in Europe and in the last couple of weeks, Zoho CRM takes minutes even to load modules. Is there a specific reason this is happening? Is this happening to other people?
                                                                                                  • Modules are continuously loading

                                                                                                    Hi! We are not able to open the task modules, it keeps continuously loading
                                                                                                  • Execution failure when fetching a Name field from another app

                                                                                                    In creator I have one app [Employee Directory] with a form [Employees]. One of the fields is a name field called [Name]. Here is a sample that works, if executed from the Employees app: test_Employee = Employees[Name.first_name == "Alex"]; info test_Employee.Name;
                                                                                                  • Next Page