Function 58: Custom calculation in item table of invoices (2 fields)

Function 58: Custom calculation in item table of invoices (2 fields)



Hello everyone, and welcome back to our series!

In Zoho Books, the Item Amount in invoices is calculated by multiplying the Quantity and Rate fields. Previously, we shared a function to include a custom field in this calculation.  Today, we are taking it a step further to make it even more versatile for various business needs. Instead of just one custom field, you can include two custom fields to determine the Item Amount.

Item Amount = Custom Field 1 × Custom Field 2 × Rate × Quantity

Consider Mr. John Hector, who runs a steel production plant. He processes orders for steel sheets according to their dimensions. For accurate billing, he can utilize today's function. When creating the invoice, John can enter the length and width of each steel sheet into the custom fields and specify the number of sheets ordered, and the rate per square foot in the default fields. The function will automatically calculate the Item Amount using this formula:

Item Amount = Length × Width × Quantity × Rate



Prerequisites: 

1. Create a Connection named "zbooks" to successfully execute the function. You can watch the GIF attached below to know how to create the connection. 



2. Create the third (Length) and fourth (Width) variables as item-level custom fields (Decimal type) to be displayed in the sales transactions.



3. Similarly, create another custom field called " Unit Rate" to be displayed in the item table. The purpose of this custom field is to store the original sales rate of the line item. 



Custom Function:

Navigate to Settings -> Automation -> Workflow Actions -> Custom Functions -> +New Custom Function -> Add the function code from this GitHub link -> Save.

Workflow Rule:  

Go to Settings -> Automation -> Workflow Rules -> +New Workflow Rule and set up the workflow rule as shown below:-





In the final step of this workflow rule, associate the custom function you created and then hit Save.

Here's how the function will work:

The custom function will be executed once the invoice is saved. Initially, it copies the original sales rate to the Unit Rate (Custom) field. Then, it multiplies Length × Width × Unit Rate and populates the result in the Rate (Default) field. Following this, Zoho Books calculates Rate (Default field) × Quantity and fills the result in the Amount field.

Note: If you wish to hide the "Rate" - default field at the template level, go to Settings > Customisation > PDF Templates > Invoices > Edit > Table > Disable the checkbox for Rate field > Save. Now, the Custom Field 1 (Length), Custom Field 2 (Width), Unit Rate (Custom Field), Quantity and the Amount field will be displayed on the invoices.



If you have to incorporate two extra values into your Item Amount calculation, this function is perfect for you. For further customization or assistance, please reach out to our Support team at support[at]zohobooks[dot]com. We're here to help!

Regards,
Shireen Farhana
Zoho Cares

    Nederlandse Hulpbronnen


      • Recent Topics

      • Is there a way to force a page refresh after changing a Subform via Workflow / Function?

        I have a workflow which triggers a function, and in this function i am changing the values of a certain subform. The changed are only visibile when i manually refresh the page and this is a no-no for my use-case. When other workflows, that change certain
      • Enable Full Theme Editor for Help Center (Disable Express Builder)

        Dear Zoho Support, We are currently using the Elegant theme in Zoho Desk Help Center, but we only have access to the limited Express Builder. We would like to switch to the full Theme Editor to be able to: Access Language Strings Edit all pages (HTML/CSS/JS)
      • Zoho Desk - account and contact lookup by phone

        Hi team, Does Zoho Desk allow to lookup Accounts and Contacts by phone or not? I am using this endpoint- GET https://desk.zoho.eu/api/v1/accounts/search?phone=987-654-3210 But I am getting this error- { "errorCode": "UNPROCESSABLE_ENTITY", "message":
      • Way to export / import a Flow between different accounts?

        Hi, I developped some flows in my account and see that for some other organisation I'm working with, they would need the same or similar flows. Is there a way for me to export one flow from one account and import it to another ? This would be handy, as
      • Setting admin only field values in widget

        Hello If I'm using a Widget addRecord function invoked by a user input (the user has write permission not developer) can he set values to a field that is set to be visible to Admin only?
      • Option to Delete Chats in IM

        Currently, there is no option to delete any chats in IM, regardless of their source.
      • Stop completed task lists from disappearing?

        Is there any way to stop projects from making tasks lists disappear when all the tasks in the list are completed? That's one of those little things where we're constantly fighting the product. For instance we have some projects which are ongoing - no start and end date. We use Kanban view to show the various task lists. We don't want the kanban list to disappear every time the items on it happen to be closed out. Thanks
      • Adding Coloured Picklist Based On Email Body Text

        Hey All, So i am having this problem, Im currently trying to automate a coloured picklist so that when the body of an email contains a specific word it will assign one of my coloured picklist i have created automatically, But it appears this only works
      • Zoho Desk is extremely slow

        Hi Team, We are facing extreme latency issue with Zoho Desk. It is currently unusable. I have submitted a ticket already could you please look into this asap. Regards, Priya Sharna
      • Zoho Desk is extremeley Slow

        Hi, Zoho Desk seems to be extremely slow for the last 15 mins for everyone in our team (5 people). https://status.zohocloud.ca/ didn't show any status in this regard. Would it be possible to have an idea what is happening and when this should be resolved?
      • Help Centre - Widget or Tab for Customer Downloads

        USE CASE: We are a software vendor, using Zoho Desk (as part of a Zoho One subscription) to help mange support issues from our customer base. Customers can log tickets via email or Help Centre portal. QUESTION: I need to provide the capability for our
      • Limits on workflow never disclosed, not documents and now being applied. I feel scammed and there is no reply for support.

        Hello everyone, I’m facing a critical issue with Zoho Recruit and would appreciate any insights from fellow users or someone from Zoho. For months, I’ve been receiving daily emails stating that I have reached the maximum workflow custom functions limit.
      • report on lead status history in zoho crm

        I have enabled the lead status history. I want to understand how many days a lead is waiting in which stage and the number of leads vs. stage history, like 0 days, 1-4 days, 5 days above, and 10 days above.
      • Cannot send a Campaign. No Send or Proceed button

        I have built a Campaign. I had to drop Leads and only use Contacts because only one group can sync. But now I do not see any errors but I do not see anyway to proceed with sending the campaign?
      • Accounts module not displaying in Campaigns sync

        When syncing CRM to Campaigns, I can only sync Leads and Contacts. Accounts module is setup and not sure why I can't select it. I won't be able to make segments for all our email campaigns. What is the resolution?
      • Missing Date Field Type Blocking VAT Calculations in Custom Zoho CRM Module

        I'm working on a custom VAT calculator within Zoho CRM where I need to store the purchase date of a product and calculate VAT based on that date, since VAT rates can vary over time. However, while creating custom fields, the only available data type is
      • Auto End Chats After Customer Inactivity

        Hello Everyone, I may be missing something, but is there a way to auto-end chats when a customer has been inactive for an amount of time? I have several operators (we use a shared set of account with schedules for people... that's another story) but at
      • Real-Time Screen Annotation During Zoho Cliq Screen Sharing

        Hi Zoho Support Team, Hope you're doing well. We’d like to request the addition of real-time screen annotation tools during screen sharing sessions in Zoho Cliq video calls. 🔍 What We're Looking For: The ability for the presenter—and optionally, other
      • Simplify ticket replies with intelligent writing and content analysis tools

        Introducing a smarter, faster way to handle ticket responses with generative AI-powered capabilities, now available in the ticket detail view. These enhancements are designed to reduce agent effort, improve clarity, and elevate the overall support experience.
      • Zoho Books - Feature Request - Show Custom Template Preview

        When using a custom template is would be a great user experience if the custom template could be previewed when viewing the record. I have found that it's very confusing for users, when they see an invoice preview but the out put file is different. Additional
      • run a macro on a contact that bounced from crm email merge

        how would one run a macro on a contact that bounced from crm email merge? how would i tell zoho to run a macro that SIGNALS said bounced?
      • Search handwriting using sketch card and OCR

        Hi It's possible using Sketch Card for handwriting and search them using AI and OCR in Pro edition? Thanks
      • Autoresponders in Zoho CRM will be discontinued—transition to Cadences for enhanced engagement

        Update (June 30, 2025): As of June 30, 2025, users will no longer be able to create or edit Autoresponders in Zoho CRM. This restriction has been put in place to ensure a smooth and guided transition to Zoho Cadences—a more powerful and flexible tool
      • Recovering a note

        Hi, I accidentally deleted an important academic not from my notebook. Can I recover it? Thanks
      • Unable to schedule posts!

        Hi everyone, I'm on the free account. I just realised it doesn't give me the options to schedule posts anymore, I can only 'post now'. I don't understand why I can't even see what I scheduled before. Can anyone help? Thanks, Benedetta
      • SPF, Zoho Books, Send from my domain

        I am unable to verify my domain through Zoho Books: this is the text record: v=spf1 include:spf.protection.outlook.com include:zohomail.com -all I waited 24 hours already with error: SPF record not found. Contact your domain provider.
      • How do I record timesheet invoices generated in Zoho Workerly against a Sales Order?

        We have customers who issue us a Purchase Order for an aggregate amount of hourly services, which we invoice against on a weekly, bi-weekly, or monthly basis (contract dependent). For simplicity, let's say the customer PO is for $50,000 (1,000 hours at
      • One Place for All Your Automation Needs

        All automation settings are grouped under Settings ()> Automation. This helps you find everything related to automation from one place. Under Workflow Rules, Email Alerts, Email Templates, and Webhooks: Use the Projects tab for project-specific settings.
      • header and footer for templates

        Hi,   I created many templates for my activity. Nevertheless I have a big problem, the HTML is varies from a quote to another, there is sometime less or more text. In order to have a nice layout I require Header and Footer. I looked for into the CRM tool, couldn't find it. Can someone explain to me if it's possible ??   It's very urgent, thanks very much,   Eric Marois
      • Onboarding Zoho sign documents?

        I was wondering something about using the Zoho sign integration with the candidate onboarding process. We set up the entire onboarding process and we have added documents that the candidate needs to review and sign digitally using Zoho Sign. This part
      • Automate Pricebook per Customer

        Example Scenario: I want to create a customer package (Silver Package, Gold Package, Platinum Package) and associated it with a Price Book that contains discounted prices for certain products. When a customer assigned to this Silver Package places an
      • Automate pricebook per customer

        Example Scenario: I want to create a customer package (Silver Package, Gold Package, Platinum Package) and associated it with a Price Book that contains discounted prices for certain products. When a customer assigned to this Silver Package places an
      • Automate pricebook per customer

        Example Scenario: I want to create a customer package (Silver Package, Gold Package, Platinum Package) and associated it with a Price Book that contains discounted prices for certain products. When a customer assigned to this Silver Package places an
      • Document Tracking

        Hi all Zoho crmplus user here. I am migrating from hubspot and in Hubspot when my sales team email a document they can see when the client has opened the document and how many minutes they sepend on it. This persists for additional openings and readings
      • Apply partial payments to invoices from the Banking Module

        We need this! Why is this not possible?
      • Forecast UI improvements

        Hi I have two improvement requests for the UI in the Forecast function. Can you add the ability to reorganise the Pipeline, Committed and Best Case columns on the Forecast? I thought they were in alphabetical order, so we renamed them so that we could
      • Missing services/ features / buttons

        Hello, 1. I can't locate the DKIM information in ZoHo CRM that I need to add as txt strings to our DNS in GoDaddy. 2. In other activities I cannot locate the 'Help' button for context senstivie help 3. I wish to merge two records into a single record
      • [Free Webinar] Building Data Relationships Using Lookup Fields - Creator Tech Connect

        Hello Everyone! We welcome you all to the upcoming free webinar on the Creator Tech Connect Series. The Creator Tech Connect series is a free monthly webinar that runs for around 45 minutes. It comprises technical sessions in which we delve deep into
      • Episode I : Exploring the World of Custom Functions in Zoho Desk

        Hello Again! Welcome to an Automation Adventure in the World of Zoho Desk Join us on a journey to explore how custom functions can enhance and extend the capabilities of Zoho Desk. Automation is everywhere. From robotic arms assembling products on factory
      • Free Webinar - Overview of Zoho Sign and latest updates- May 2025

        Hello there! What's the digital alternative to endless paperwork? Zoho Sign. Designed for digital-first businesses, Zoho Sign is a complete digital signature solution with powerful features and seamless integrations that streamline your entire workflow.
      • Next Page