- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 07:34 AM - edited 09-28-2023 07:50 AM
Pretty simple question, but it has me stumped. I need to move a user's phone number to a single line text variable. How do I do that ?
g_form.setValue('telephone', usr.phone); doesn't work. Seems like have to do with the users phone number field is set up a 'phone number' and there is no variable type for phone number. I have location working fine, g_form.setValue('location', usr.location);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 07:53 AM
Have you tried forcing it to a string?
g_form.setValue('telephone', usr.phone.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 07:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 07:53 AM
Have you tried forcing it to a string?
g_form.setValue('telephone', usr.phone.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 07:56 AM
Thanks Brad, that worked !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 09:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 11:41 PM
Since the phone number field in ServiceNow (or similar platforms) is set up as a "phone number" type, it's not just a simple text field and might have some additional formatting or validation that prevents g_form.setValue('telephone', usr.phone) from working as expected.
To move the phone number to a single-line text variable, you can try converting the phone number value into a string and removing any non-numeric characters (like parentheses or hyphens) before setting it to the text field. Here’s how you could do it:
This way, you'll store the phone number in a plain format without any special characters, which should allow it to work with a single-line text field.