Set the Mobile phone through script (Phone Number (E164))

TanayaGavande
Tera Expert

Hi All,

 

For a user in the sys_user table, I have the field mobile_phone, of type Phone Number (E164).

TanayaGavande_0-1722619525624.png

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.

TanayaGavande_1-1722619641743.png

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?

6 REPLIES 6

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. 

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.