Set the Mobile phone through script (Phone Number (E164))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 10:28 AM
Hi All,
For a user in the sys_user table, I have the field mobile_phone, of type Phone Number (E164).
I am working in the background script to update the value of the number to any number. eg. 91 5658874526. This should ideally work as I am getting a row count 1 for update after script execution.
However, the phone number in the user records is empty and when I log the value again, it is empty as well. How can I set the value of the mobile of a user through script?
Is there anything I am skipping?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 10:18 AM
Hi @SN_Learn ,
Yes, the field is Phone Number (E164). There was an integration with Twilio a while ago (whose configuration I haven't done), and since then the country codes have changed. What I want to do is change the numbers back to how they were before, via a script or anything that helps. Your code works perfectly in my PDI, but not for the client environment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 10:48 PM
Hi @TanayaGavande ,
Could be the reason that any existing script is running on that field. I am not able to replicate the scenario in PDI.
Please try the below and check:
var updateNumber = new GlideRecord('sys_user');
if (updateNumber.get('62526fa1d701120035ae23c7ce6103c6')) {
updateNumber.setValue('mobile_phone', '+14131234567');
updateNumber.setWorkflow(false);
updateNumber.update();
}
Mark this as Helpful / Accept the Solution if this helps.