Phone number format for users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
Hello Community,
I would like to change the format of the Mobile phone (mobile_phone) field in the User [sys_user] table.
Currently, the phone numbers are displayed in the following format:
Example: 1(449) 260-6439
However, I would like the numbers to be displayed and stored in a simple numeric format like:
Example: 06212348725
Requirement:
I want the Mobile phone number to:
Be displayed exactly as entered
Not automatically formatted with country code, parentheses, or dashes
Use a plain numeric format (example: 06212348725)
Althout i have disable the sys properties for us format but u still have the probleme :
Sys_properties : glide.ui.format_phone
Thank you for help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi @ahmed-24
what is the use case change data type of the Phone Number field. It is not recommended because this field is used in On-Call, FSM, and CSM as well. If it is changed to a string, users would be able to enter anything, which would not be the correct behavior.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
hello @Dr Atul G- LNG
I would like to change the format of the Mobile phone (mobile_phone) field in the User [sys_user] table.
Currently, the phone numbers are displayed in the following format:
Example: 1(449) 260-6439
However, I would like the numbers to be displayed and stored in a simple numeric format like:
Example: 06212348725
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @ahmed-24
What is the use case for converting this data type to a string? What are you trying to achieve by changing it?
Please consider that this field is not just a phone number field—it is used for on-call purposes, CSM, FSM, and other integrations where messages are sent to phone numbers. Changing the data type would disrupt all of these functionalities.
This data type is by design and serves a specific purpose, so it should not be changed. If you need additional flexibility, it would be better to create a new field and, through logic, convert it to a string and use it instead, rather than modifying the existing platform field.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 5 hours ago
HI @ahmed-24 ,
setting the system property (glide.ui.format_phone) to false is working for me
if you still facing the issue try clearing the cache or try to use a different browser or try incognito mode
if you are still facing the issue
try this
create a client script on sys_user table
function onLoad() {
if (g_form.hasField('mobile_phone')) {
var mp = g_form.getValue('mobile_phone')
if (mp) {
g_form.setValue('mobile_phone', mp.replace(/[^0-9]/g, ""));
}
var mobilePhone = g_form.getControl('mobile_phone');
mobilePhone.setAttribute('onChange', '');
}
if (g_form.hasField('phone')) {
var phone = g_form.getValue('phone')
if (phone) {
g_form.setValue('phone', phone.replace(/[^0-9]/g, ""));
}
var phoneElement = g_form.getControl('phone');
phoneElement.setAttribute('onChange', '');
}
}
also you would have to run a fix script or Background script to fix the existing data
var userGR = new GlideRecord("sys_user");
userGR.addEncodedQuery("mobile_phoneISNOTEMPTY^NQphoneISNOTEMPTY");
// userGR.setLimit(10);
userGR.query();
while (userGR.next()) {
var mp = userGR.getValue('mobile_phone')
if (mp)
userGR.setValue('mobile_phone', mp.replace(/[^0-9]/g, ""))
var phone = userGR.getValue('phone');
if (phone)
userGR.setValue('phone', phone.replace(/[^0-9]/g, ""))
userGR.update()
}result
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
