Welcome back everyone!
Last week, we learnt how to add pre-defined notes in a click. This week, let's look at a custom function that helps you add the invoice grand total in words with the click of a button.
Business scenario:
Countries across the globe follow different numbering formats with comma and decimals being used interchangeably:
- In the US, comma (,) is used as thousands separators where as in Germany, period (.) is used.
- In the US, period (.) is used as decimal separator where as in Germany, comma (,) is used.
Thus, three thousand fifty-five and eight tenths is displayed as 3,025.8 in the US and 3.025,8 in Germany. For cheques, the practice of writing the amount in words not only helps avert malpractice, but also clears any discrepancies associated with number format. If you are dealing with multi-national clients, it is best to extend this practice to your client invoices, and this weeks custom function helps you achieve just that with the click of a button.
Getting started with the custom function:
- Go to Setup > Automation > Actions > Custom Functions > Configure Custom Function > Write your own .
- Provide a name for the button. For example: “Total in words”. Add a description(optional).
- Choose the module as " Invoice ".
- Click “ Free flow scripting ”.
- Copy the code given below.
- Click “ Edit arguments ”.
- Enter the name as “ invoiceId ” and select the value as “ Invoice Id ”.
- Save the changes.
- Click Save to create the button.
The script:
Code for Version 2.0 API:
invoiceDetails = zoho.crm.getRecordById("Invoices", input.invoiceId.toLong());
val_s = ifnull(invoiceDetails.get("Grand_Total"),"0").toLong();
//val_s=input.val.toString();
th = {"", "thousand", "million", "billion", "trillion"};
// uncomment this line for English Number System
// th = {"","thousand","million", "milliard","billion"};
dg = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
tn = {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
tw = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
x = val_s.length();
if (x > 15)
{
info "too big";
}
else
{
s = val_s.replaceAll("(?)",",",false).removeFirstOccurence(",").removeLastOccurence(",").toList();
str = "";
sk = 1;
bypass = false;
for each index i in s
{
cur = (s.get(i)).toLong();
info cur;
if (!bypass)
{
if (((x - i) % 3) == 2)
{
if (cur == 1)
{
next = (s.get((i + 1))).toLong();
info next;
str = (str + tn.get(next)) + " ";
bypass = true;
sk = 1;
}
else if (cur != 0)
{
str = (str + tw.get((cur - 2))) + " ";
info str;
sk = 1;
}
}
else if (cur != 0)
{
str = (str + dg.get(cur)) + " ";
info str;
if (((x - i) % 3) == 0)
{
str = str + "hundred ";
sk = 1;
}
}
}
else
{
bypass = false;
}
if (((x - i) % 3) == 1)
{
if (sk != 0)
{
str = (str + th.get(floor(((x - i - 1) / 3)))) + " ";
info str;
sk = 0;
}
}
}
info str;
}
upperstr = str.toUpperCase();
mp = map();
mp.put("Grand_Total_in_Words", upperstr);
update = zoho.crm.update("Invoices", invoiceId.toLong(), mp);
info mp;
info update;
Code for Version 1.0 API:
invoiceIdStr = input.invoiceId.toString();
invoiceDetails = zoho.crm.getRecordById("Invoices", input.invoiceId);
val_s = ifnull(invoiceDetails.get("Grand Total"),"0");
//val_s=input.val.toString();
th = {"", "thousand", "million", "billion", "trillion"};
// uncomment this line for English Number System
// th = {"","thousand","million", "milliard","billion"};
dg = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
tn = {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
tw = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
x = val_s.length();
if (x > 15)
{
info "too big";
}
else
{
s = val_s.replaceAll("(?)",",",false).removeFirstOccurence(",").removeLastOccurence(",").toList();
str = "";
sk = 1;
bypass = false;
for each index i in s
{
cur = (s.get(i)).toLong();
info cur;
if (!bypass)
{
if (((x - i) % 3) == 2)
{
if (cur == 1)
{
next = (s.get((i + 1))).toLong();
info next;
str = (str + tn.get(next)) + " ";
bypass = true;
sk = 1;
}
else if (cur != 0)
{
str = (str + tw.get((cur - 2))) + " ";
info str;
sk = 1;
}
}
else if (cur != 0)
{
str = (str + dg.get(cur)) + " ";
info str;
if (((x - i) % 3) == 0)
{
str = str + "hundred ";
sk = 1;
}
}
}
else
{
bypass = false;
}
if (((x - i) % 3) == 1)
{
if (sk != 0)
{
str = (str + th.get(floor(((x - i - 1) / 3)))) + " ";
info str;
sk = 0;
}
}
}
info str;
}
upperstr = str.toUpperCase();
mp = map();
mp.put("Grand Total (in Words)", upperstr);
update = zoho.crm.updateRecord("Invoices", invoiceIdStr, mp);
info mp;
info update;
This is how the result looks like:
Note:
- Create a custom field named 'Grand Total (in Words)' in your invoice module. Note that this is part of the code (mp.put("Grand Total (in Words)", upperstr);). Just in case you use a different field name, update the code accordingly.
- The above code adds the grand total in words in your invoice record.
- Use merge fields to reflect the same in the invoice templates to be sent to your clients
- This custom function handles up to 15 digits and rounds-off to the nearest whole number.
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. Do check out other custom functions shared in this serieshere.
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. Recent Topics
Add Support for Authenticator App MFA in Zoho Desk Help Center
Hello Zoho Desk Team, We hope you are doing well. We would like to request an enhancement related to security for the Zoho Desk Help Center (customer portal). Currently, the Help Center supports MFA for portal users via SAML, JWT, SMS authentication,
Can no longer upload my own Notebook cover
I've had Notebook for over a year and have been able to create my own notebook covers, but when I tried to upload my own cover for a new notebook today, the upload feature has suddenly been starred, requiring me to upgrade my account. When did this
External File Share - Allow delete
Hi Team, when I share an external link and give it edit rights the external user can add but not delete files and folders. what am i doing wrong?
Elevate your CX delivery using CommandCenter 2.0: Simplified builder; seamless orchestration
Most businesses want to create memorable customer experiences—but they often find it hard to keep them smooth, especially as they grow. To achieve a state of flow across their processes, teams often stitch together a series of automations using Workflow
Zoho Desk - Cannot Invite or Register New User
Hi who may concern, we encountered a problem that we cannot invite user or the visitor cannot register for a user at all through our help center portal, with the snapshot shown as below and the attachement. It always pops up that "Sorry, Unable to process
Kaizen# 209 - Answering Your Questions | All About Client Script
Hello everyone! Welcome back to another exciting Kaizen post! Thanks for all your feedback and questions. In this post, let's see the answers to your questions related to Client Script. We took the time to discuss with our development team, carefully
Allocating inventory to specific SO's
Is there a way that allocate inventory to a specific sales order? For example, let's say we have 90 items in stock. Customer 1 orders 100 items. This allocates all 90 items to their order, and they have a back order for the remaining 10 items which could
Reports: Custom Search Function Fields
Hi Zoho, Hope you'll add this into your roadmap. Issue: For the past 2yrs our global team been complaining and was brought to our attention recently that it's a time consuming process looking/scrolling down. Use-case: This form is a service report with
Custom domain issue
I recently changed records for my support area custom domain for a few months, I then wanted to come back to Zoho, but now I can't connect it and I can't login as it's having an SSL issue. I cannot get a good response from support, as I've been notified
SOME FEATURES ARE NOT IN THE ZOHO SHEET IN COMPARISION TO ZOHO SHEET
TO ZOHO sir/maam with due to respect i want to say that i am using ZOHO tool which is spreadsheet i want to say that some features are not there in zoho sheet as comparison to MS EXCEL like advance filter and other Features which should be there in ZOHO
Zoho Sheet - Desktop App or Offline
Since Zoho Docs is now available as a desktop app and offline, when is a realistic ETA for Sheet to have the same functionality?I am surprised this was not laucned at the same time as Docs.
How do you generate personalized certificates and save them in dynamic folders using Writer's mail merge?
Zoho Writer's mail merge feature can help you enhance the certificate management process. It's a great way to save time and effort! Merge certificates and maintain a well-organised repository with personalised certificates stored in separate folders for
Zoho Editor
Zoho PDf Editor is not working I am clicking on EDIT PDf then it again bringing me back to the same page. again and again.
The present is a "present"
The conversation around mental health has been gaining attention in recent years. Even with this awareness, we often feel stuck; the relentless pace of modern life makes us too busy to pause, reflect, and recharge. In the world of customer support, this
Export as MP4 or GIF
Hi, Just wondering if there's a way to export/convert a presentation to an MP4 video file or even a GIF. One use case would be to use the animation functionality to create social media graphics/charts/gifs/videos. Thanks for a great tool... Rgds Jon
Zoho Autoplay Issue
Currently, we run our graphics on a playlist with youtube videos interspersed in our office -- however, when we go to update the playlist (since last Thursday at around 8-9am EST) it no longer saves the autoplay function. We have tried making a new account, manually saving with cntrl+s, making a new show, etc but nothing seems to work. Even with our old program, we can't change it off of autoplay for ones that were created in the past. Another issue is that if we change a slide transition to anything
Zoho Sheet Autofit Data
While using Autofit Data function in Zoho Sheets with Devnagri Maratji or Hindi Fonts, a word or a number, it keeps couple of characters outside the right side border.
KPI Widget dashboard select periods
I have a problem with selecting periods as a user filter. In the beste scenario I would like to have to have a period filter like Google Analytics has of Datastudio (see attachment). In the KPI widget I "Group by "inquiry_date" on week&Year". It selects
Search in Zoho Community Not Working
I realize this is a bit of a meta topic, but the search for the various Zoho Communities appears to not be working. I'm under the impression that they run on some version of the Zoho Desk platform, so I'm posting this here.
Kaizen #152 - Client Script Support for the new Canvas Record Forms
Hello everyone! Have you ever wanted to trigger actions on click of a canvas button, icon, or text mandatory forms in Create/Edit and Clone Pages? Have you ever wanted to control how elements behave on the new Canvas Record Forms? This can be achieved
Workdrive on Android - Gallery Photo Backups
Hello, Is there any way of backing up the photos on my android phone directly to a specific folder on Workdrive? Assuming i have the workdrive app installed on the phone in question. Emma
The Social Wall: September 2025
Hello everyone, As we step into the fall season, some major updates are on the horizon. Meanwhile, here are the exciting updates we rolled out this September. Approvals in iOS Managing approvals just got more seamless on mobile. With this update, the
Add a Way to Duplicate Cards in the Same Canvas (Retain All Settings)
Dear Zoho SalesIQ Team, We would like to request a new feature in Zoho SalesIQ: the ability to duplicate an existing card within the same canvas while retaining all of its information and settings, including conditions, configurations, and display preferences.
Market cap
Market cap formula?? Kaise nikale
Zoho Sheet for Desktop
Does Zoho plans to develop a Desktop version of Sheet that installs on the computer like was done with Writer?
Google enhanced conversions not working
Hi guys, I've connected Zoho CRM through Google Ads interface with the goal to setup the enhanced conversion tracking in Google Ads. I have to Zoho related conversion goals which you can see in the images below: For the conversion goal above I've setup
Need Help to setup plugs along with codeless bot buidler. To send sms OTPs to users via Zoho Voice and to verify it
Need Help to setup plugs along with codeless bot buidler. To send sms OTPs to users via Zoho Voice and to verify it. I get leads from our website and we need to make sure those are not junk. So we are using proactive chat bot and we need mobile OTPs to
Direct Integration Between Zoho Cliq Meetings and Google Calendar
Dear Zoho Team, We’d like to submit the following feature request based on our current use case and the challenges we’re facing: 🎯 Feature Request: Enable meetings scheduled in Zoho Cliq to be automatically added to the host's Google Calendar, not just
Zoho sheet
Unable to share zoho sheet with anyone on internet with editer option only view option is show
Mail and OS
Jai Hind! Zoho is doing good by creating good software (made in india) on par with other tech giants. 🥰 Suggestion: 1. Whenever we sign up on zoho mail its asking for other mail id. It shouldn't be like that. You should ask general details of a user
Personal account created under org account
Hi there, I am Jayesh. We are using ME Central, and we have an account by the email ID soc@kissht.com.. Now I have created a personal account., jayesh.auti@zohomail.in, accidentally. Can you help me to remove this jayesh.auti@zohomail.in from my organization
Add another account
How to add another mail account to my zoho mail.
Recover deleted user
Hi by mistake i have deleted an added user and his email associated. Please help me recover it thank you.
No connection to the server
Hello! I can't add a new email address to my mailbox because your server is rejecting me. Please help. I took and added a screenshot of this problem Marek Olbrys
URGENT: Business Email Disruption – SMTP Authentication Failed
Dear Zoho Support, I am writing to escalate a critical issue with my business email account: 📧 marek@olbrys.de My domain olbrys.de is fully verified in Zoho (MX, SPF, DKIM, DMARC all valid – green status). I am using the correct configuration: smtp.zoho.eu
Emails missing from desktop but visible on phone
Subject says it all. Windows 11 laptop. Apple phone. all systems up to date.
Website Hosting
Hello, I want to host my domain on Hostinger, and I want my emails to run through Zoho Mail. Please provide me with the SPF record, MX record (Type: TXT), and A record, so that I don’t face any issues with my emails. My website is on Hostinger hosting,
Can not search zoho mail after update V.1.7.0
i can not search mail on to and cc box from attached picture and then search contacts box can't click or use anything. include replay mail too.
Urgent Security Feature Request – Add MFA to Zoho Projects Client Portal Hello Zoho Projects Team,
Hello Zoho Projects Team, We hope you are doing well. We would like to submit an urgent security enhancement request regarding the Zoho Projects Client Portal. At this time, as far as we are aware, there is no Multi-Factor Authentication (MFA) available
How to retreive the "To be received" value of an Item displayed in Zoho inventory.
Hi everyone, We have our own Deluge code to generate a PO according to taget quantity and box quantity, pretty usefull and powerful! However, we want to reduce our quantity to order according to "To be received" variable. Seems like this might not even
Next Page