Custom Function to Format Phone / Mobile numbers in Australian Standard format

Custom Function to Format Phone / Mobile numbers in Australian Standard format

So I got sick of phone numbers being formatted incorrectly and Zoho not doing anything to standardise phone numbers to meet E.164 formats. So I went and coded my own function to fix this.
And figured I'd share with the community

This is specifically for Australian numbers. 

The CF will take all mobile, local landline, 1800 & 1300 numbers and format them into the format we are used to in Australia.
It will also add the country code +61 to the prefix so you can call directly from the CRM.

It works with all 10 digit numbers (0400 000 000 or 03 9000 0000)
And with all 9 digit numbers (400 000 000 or 3 9000 0000)
IE works with both the starting 0 or without the starting 0 (ie 03 9000 1111 or 3 9000 1111)


The numbers will be formatted as below


All mobile numbers    0400111222 --> +61 400 111 222
                                       400111222 --> +61 400 111 222
All local numbers        0390001111 --> +61 3 9000 1111
                                       390001111 --> +61 3 9000 1111
1800 numbers            
1800111222 --> +61 1800 111 222
1300 numbers            1300111222 --> +61 1300 111 222

For the local numbers it will work with all states area codes (02, 03, 07, 08)

Anything that isn't the above will be ignored and stay the way it was. IE 131122 will stay like that
As will any numbers that aren't 9 or 10 digits long. (ie +61400111222 wont be formatted with spaces)

**NB I may do a V2 to format numbers that are +61 already but not planning that for a while.

This function is specifically for the Leads module.
It is Phone/Mobile Field agnostic. In that it will take whatever value is in the Phone Field, format it return it to the Phone Field. and what ever is in the Mobile Field, format and return it to Mobile Field.

I did this specifically as we use Phone to be the contacts Primary contact number and Mobile to be their Secondary contact Number.

It should be pretty easy to adapt to Contacts Module or any other module. You only need to change line 1 & 211.


Setting up with Workflow and Triggering the Function:
This applies for CRM
  1. Go to Setup --> Automation --> Workflow Rules --> Create Rule --> Under Module, select Leads --> Give a Rule name and Description (ie Format Phone Numbers Australia) --> Next
  2. When = Select "On a Record action" --> "Create or Edit" --> Next
  3. Condition = In Conditions, choose "All Leads" --> Next.
  4. Instant Actions --> Function --> New Function --> Write your own --> Add a Function name (ie Format_Phone_Numbers_Au), Display Name (ie Format Phone Numbers Australia), Description --> Create
  5. Copy paste the code from below and proceed to save the code.
  6. "Edit the Arguments" --> Key is id, in Param Value type # and choose your fields (ie Leads and Lead Id) the end result should read id = Leads - Lead Id --> Save
  7. Save the Function 
  8. Save the Workflow.


NOTE: there is probably a better more efficient way of achieving this.
So if anyone know a better way to code the above I'd love to hear.

EDIT: I had to upload the code separately due to restrictions in the post lengths.

EDIT 2: now updated to work with brackets (03) 9000 1111 and hyphens 0400-000-000

EDIT 3: updated to work with the country code already added but no + ie 61400111222  


The number formatting will work with the following

All mobile numbers    --> +61 400 111 222
  1. 0400 111 222
  2. 400111222
  3. 0400-111-222
  4. 61400111222
All local numbers  --> +61 3 9000 1111
(works with 02, 03, 07, 08) 
  1. 0390001111                  
  2. 390001111
  3. (03) 9000 1111
  4. (03) 9000-1111
1800 numbers  --> +61 1800 111 222
  1. 1800111222
  2. 1800 111 222
1300 numbers  --> +61 1300 111 222
  1. 1300111222 
  2. 1300 111 222 


EDIT: May 2025

Theres been some requests about cleaning up existing phone numbers for leads/contacts.

To do this there are a few steps to do.

Step 1 - create a new Custom Function called "Format Phone Numbers Au - mass update"
(or what ever you want to name it)

Use the same code as the single run fuction and add a recurring "loop" section to the start of the code, and a small closing at the end.
The way I have it setup is to use the following opening code before Line 1. 
Line 6 of the below code replaces Line 1 in the full code.

  1. string button.Format_Phone_Numbers_Au_mass_update(String leadIDs)
  2. {
  3. idList = leadIDs.toList("|||");
  4. for each  rec in idList
  5. {
  6. a = zoho.crm.getRecordById("Leads",rec);

Then to close the function replace the final Map (line 208-213) with the following

  1. }
  2. mp = Map();
  3. mp.put("Phone",nph);
  4. mp.put("Mobile",nmob);
  5. update = zoho.crm.updateRecord("Leads",rec,mp);
  6. info mp;
  7. info update;
  8. }
  9. return "Success";
  10. }

This new function will take your selected list of Leads and then "for each Record in the idList will run the function"

Step 2 - Create a Mass Update Button in the List view of the Leads/Contacts Module

Go to Settings > Customizations > Modules and Fields > [Module Tab} > Leads
Then go the the Buttons tab > Create New Botton

Button Name: Phone Numbers Mass Update
Define action: Function
Select Page: In List
Select Position: Mass Action Menu  (preview to see where the botton will be placed)
Configured Function: Select the function you created in the above step

Doing the above will create a new botton in the main list view for the Module. 
To use the button you need to select the entries you want to run the function then click the button.

Step 3 - Create a custom View for your Leads/Contacts so that you have less than 1000 

Zoho CRM Limits mass update functions to run for max of 1000 entries at a time. So if you have 10,000's leads you need to figure out how to narrow your view down to less than 1000 entries.

One way is to create a View with specific criteria like 
Email starts with A - this will show all leads with email address beginning with A
If this is still more than 1000 then figure out how to reduce it further to less than 1000

Step 4 - Select all records
Select the check box of the view at the top of the Column. This will select all records in the current window.
Windows are limted to 100 records, so you need to select all 1000 
You will then see a Blue text option to "Select All records in this view". Click this and all records will be selected.
If you have more than 1000 records in the view you wont be able to do the following step so make sure you've limited the view.

Step 5 - click the Mass Update button

Click the Mass Update Button you created above in Step 2. This will run the fuction for all the entries.
It'll take some time and entries will be added to the execution que. If you are interested you can check the api usage to make sure you keep your usage under the daily limit.

Step 6 - Figure out how to vary your list View for the next batch

Rinse and repeat Step 3-5. 
Figure out how to change the View so you see the next 1000 batch but exclude the ones you have already done.

Step 7 - Finish

Make sure you remove the Button you created in Step 2, otherwise someone will definitily run it in future when you dont want them to.


    Access your files securely from anywhere







                        Zoho Developer Community





                                              Use cases

                                              Make the most of Zoho Desk with the use cases.

                                               
                                                

                                              eBooks

                                              Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                               
                                                

                                              Videos

                                              Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                               
                                                

                                              Webinar

                                              Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                               
                                                
                                              • Desk Community Learning Series


                                              • Meetups


                                              • Ask the Experts


                                              • Kbase


                                              • Resources


                                              • Glossary


                                              • Desk Marketplace


                                              • MVP Corner




                                                        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

                                                                                                        • Marketer's Space: Bookmarks by Zoho Campaigns

                                                                                                          Hello Marketers, In this week's Marketer's Space, we'll look at a simple yet powerful feature that makes a big difference in your workflow: Bookmarks. Bookmarks is a built-in feature in Zoho Campaigns that enables you to create a personalized library
                                                                                                        • Workflow for "Expenses" module?

                                                                                                          Hi there, over the last 2 years, Zoho Expense has seen tremendous growth and we are happy with it. But, sometimes it is frustrating to see things are being implemented halfheartedly, or so it seems. For example, There is the possibility to create workflows
                                                                                                        • on submit of creator form then record is create in Zoho crm purchase module then on automatically task want to create in the crm

                                                                                                          on submit of creator form then record is create in Zoho crm purchase module then on automatically task want to create in the crm
                                                                                                        • Allow Mapping of Zoho Desk Knowledge Base Categories to Multiple Departments in Zoho SalesIQ

                                                                                                          Hello Zoho Team, We hope you're doing well. We would like to request an enhancement to the Zoho SalesIQ integration with Zoho Desk, specifically regarding the way Knowledge Base (KB) articles are mapped and displayed across departments. Current Limitation
                                                                                                        • Recurring Events Not Appearing in "My Events" and therefore not syncing with Google Apps

                                                                                                          We use the Google Sync functionality for our events, and it appears to have been working fine except: I've created a set of recurring events that I noticed were missing from my Google Apps calendar. Upon further research, it appears this is occurring
                                                                                                        • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

                                                                                                          Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
                                                                                                        • [Important announcement] Zoho Writer will mandate DKIM configuration for automation users

                                                                                                          Hi all, Effective Dec. 31, 2024, configuring DKIM for From addresses will be mandatory to send emails via Zoho Writer. DKIM configuration allows recipient email servers to identify your emails as valid and not spam. Emails sent from domains without DKIM
                                                                                                        • Desk - CRM Integration: SPAM Contacts (Auto Delete)

                                                                                                          SPAM contacts is a useful feature, but when the CRM sync is used, it is very frustrating. When a contact is marked as SPAM on Desk, I wish to do the same on CRM. When a SPAM contact is deleted, I would like it deleted from CRM. The feature looks half-baked.
                                                                                                        • View Audit Trail field

                                                                                                          The Audit Trail feature is great, but its data is only available to admin users. It would be really great to have a system field "Audit trail" that we can add to the detailed view of a record. This would allow supervisors, directors and etc. to quickly track what changes have been done by whom for each record. It is a current feature from a client of mine and while it's probably possible to hard code it, since this data is already available in Zoho, I would be surprised to hear how hard it would
                                                                                                        • Creator roadmap for the rest of 2022

                                                                                                          Hi everyone, Hope you're all good! Thanks for continuing to make this community engaging and informative. Today we'd like to share with you our plans for the near future of Creator. We always strive to strike a good balance of features and enhancements
                                                                                                        • How do I modify the the incoming/current call popup? I can modify other call pages but not that one.

                                                                                                          I want to modify the incoming and active call popup on the crm to include customer relevant information, such as purchase history or length of relationship. Under modules and fields, I don't seem to see active call as a choice to modify, only the main
                                                                                                        • Announcing new features in Trident for Windows (v.1.27.4.0)

                                                                                                          Hello Community, Trident for Windows is here with exciting new features to elevate your communication and enhance productivity. Let’s dive into what’s new! Smart Sign-in. You can now sign in to Trident with Smart Sign-in. With this new addition, you can
                                                                                                        • Add Lookup Field in Tasks Module

                                                                                                          Hello, I have a need to add a Lookup field in addition to the ones that are already there in the Tasks module. I've seen this thread and so understand that the reason lookup fields may not be part of it is that there are already links to the tables (https://help.zoho.com/portal/en/community/topic/custom-fields-on-task-module).
                                                                                                        • Global Sets for Multi-Select pick lists

                                                                                                          When is this feature coming to Zoho CRM? It would be very useful now we have got used to having it for the normal pick lists.
                                                                                                        • Time Entry : Auto fill fields Hours minutes seconds

                                                                                                          Hello world, Do someone know a script (for workflow rules) which fill automatically fields hours spent, minutes spent, seconds spent when we fill Executed time and End time Formula should start from (End time - Executed time) Thx in advance
                                                                                                        • MULTI-SELECT LOOKUP - MAIL TEMPLATE

                                                                                                          Dear all how are you? We need to insert data from MULTI-SELECT LOOKUP in a email template, but I can't do that, when I'm creating the template I can't find the field to insert it. is there any solution? PVU
                                                                                                        • Create Encrypted Zoho Forms URL for SMS Pre-Population forms using zfcrm_entity=

                                                                                                          Hello Zoho Forms Community and Zoho Team, I’m trying to send a Zoho Forms URL via SMS with pre-populated CRM contact data, inspired by a post from four years ago by GlennP (https://help.zoho.com/portal/en/community/topic/passing-the-crm). Our form is
                                                                                                        • Tracking Emails sent through Outlook

                                                                                                          All of our sales team have their Outlook 365 accounts setup with IMAP integration. We're trying to track their email activity that occurs outside the CRM. I can see the email exchanges between the sales people and the clients in the contact module. But
                                                                                                        • Zoho Forms - edit the settings of the Zoho CRM field to change the integration with CRM

                                                                                                          I've created a Zoho CRM field in my form to pre-populate selected CRM details into the form, following the instructions here https://help.zoho.com/portal/en/kb/crm/integrations/zoho/zoho-forms/articles/zoho-forms-crm-integration#Step_2_-_Add_Zoho_CRM_Field_in_the_form
                                                                                                        • Data Integration Platform

                                                                                                          Hi,  Is anyone aware about a data integration platform like Dell Boomi that can work with Zoho Support? Any help will be higghly appreciated.  Thanks Kunal
                                                                                                        • Zoho CRM Webinar – Automate everything across Customer Journeys in CommandCenter 2.0

                                                                                                          How efficient is your current CRM automation setup? As customer journeys become more dynamic, it's common for data and actions to get scattered across teams and modules. This leads to broken processes and inconsistent customer experiences—especially across
                                                                                                        • Ability to add notes to an appointment and add notes/attach docs to a consultation

                                                                                                          As an idea for the future, it would be helpful to be able to add notes to an existing appointment--there is a place to add notes for the customer, but I don't see one for the appointment. It would also be helpful to be able to add notes or attach documents
                                                                                                        • How to query Deal "Stage" "Is Open" in Analytics SQL?

                                                                                                          How do I query this "field" in Analytics? What is going on? It seems like there is another 'mapping' somewhere but that it is inaccessible with raw sql??? If I query "Stage" Like '%Won%' I get a wildly different number than I do when I manually filter
                                                                                                        • Im trying to white list domain dynamically in zoho desk extension

                                                                                                          Im trying to white list domain dynamically in zoho desk extension. But it show error Error: {errMsg: 'No entry found in plugin-manifest whiteListedDomains for requested URL'} syntax "config": [ { "displayName":"Shopify Admin API access token ", "name":
                                                                                                        • Backorder For Composite Items

                                                                                                          Hello If i released SO for composite item and use backorder feature of zoho inventory then it should backorder child item items of composite and not composite item.This is basic of backordering.I conveyed this to zoho call center but no solution yet.
                                                                                                        • Passing the CRM

                                                                                                          Hi, I am hoping someone can help. I have a zoho form that has a CRM lookup field. I was hoping to send this to my publicly to clients via a text message and the form then attaches the signed form back to the custom module. This work absolutely fine when
                                                                                                        • Zoho Payroll: Product Updates for India - May 2025

                                                                                                          This May, we are glad to unveil new capabilities in Zoho Payroll that simplify your payroll activities. Here's the list: Let Employees Choose Their Tax Deduction Method for One-Time Payments Calculate variable earnings based on percentage of CTC Carry
                                                                                                        • Enhance Zoho One Conditional Assignment to Fully Reassign App Settings When Changing Departments

                                                                                                          Hi Zoho Team, We’d like to submit a feature request regarding the current behavior of Zoho One’s conditional assignment logic when moving a user between departments. 🔧 Current Limitation As it stands, Zoho One’s conditional assignment does not remove
                                                                                                        • Sync failed: Invalid Date value

                                                                                                          Hi, I have a local .sqlite database. After importing one table through the Databridge, and produced my dashboards, I cannot sync. I get an error regarding the date column: [Line: 2 Field: 4] (2018-07-12) -ERROR: Invalid Date value The data found at the
                                                                                                        • Office 365 is marking us as "bulk"

                                                                                                          All of a sudden (like a couple of days ago) all of our customers who are on Office 365 are getting our mails in their junk email. This is not the case with Gmail or other random mail servers, nor between us. We got a 10/10 score on mail-tester.com. Also,
                                                                                                        • Zoho Assist

                                                                                                          Hi, We are using zoho assist unattended access in some windows server 2012 and recently the agent lets you connect but not let you do anything on the remote machine. Sometimes you can click on something but nothing happens. There's a issue with this new
                                                                                                        • Experience effortless record management in CRM For Everyone with the all-new Grid View!

                                                                                                          Hello Everyone, Hope you are well! As part of our ongoing series of feature announcements for Zoho CRM For Everyone, we’re excited to bring you another type of module view : Grid View. In addition to Kanban view, List view, Canvas view, Chart view and
                                                                                                        • Modify workflow from "ON CREATE & EDIT" to "ON CREATE" only

                                                                                                          Salut, Is there a way to easilly change my choice of trigger of workflow from on create & edit to on create only, or do I have to re-do the whole worklow from scratch ? Sylvain
                                                                                                        • Access custom modules via API?

                                                                                                          Is it possible to access a custom module in Zoho Inventory via the API? I can not find any reference to this in the API docs.
                                                                                                        • Welcome to the Zoho Service Plus community

                                                                                                          Hey everyone, We are excited to welcome you to be a part of the Zoho Service Plus community. Here's a quick overview of what Service Plus is all about and how the community can help us work together. What's Zoho Service Plus? Zoho Service Plus is a unified
                                                                                                        • Extensions 101 webinar series: Build, integrate, and monetize with extensions

                                                                                                          Attention developers! Are you ready to take your extension development skills to the next level? We're excited to bring back the Extensions 101 webinar series with an expanded lineup of Zoho products and an introduction to more platform features. Last
                                                                                                        • Restrict Zoho Cliq Webinars and Announcements to Admins Only

                                                                                                          Hi Zoho Team, We hope you're doing well. We would like to raise a feature request regarding in-app announcements in Zoho Cliq, such as the recent webinar popup about the Cliq Developer Platform: While these announcements are useful, they are not always
                                                                                                        • Track ZohoForm Conversion using Postmessage event

                                                                                                          Hi, I’ve been using a third-party lead tracking tool to capture leads from my website along with their source. Earlier, with the HubSpot form, the third-party script was able to detect the postMessage event that iframe forms typically send back to the
                                                                                                        • Related Lists filter

                                                                                                          I have Contacts showing in our Accounts module. I customized the Contacts module with an Employment Status field, with the following picklist options: "Primary Contact", "Secondary Contact", "Active Staff(not a main contact)", and "No longer employed".
                                                                                                        • Share Notebook with group created in Zoho One

                                                                                                          I have created a group in Zoho One for a section in my company. Is it possible to share a notebook with that Zoho One Group? Currently, it seems only possible to share to emails. Unfortunately for large teams, this will mean we are constantly having to
                                                                                                        • Next Page