Trying to populate (OOB) mobile phone number on sys_user table with variable and it's not working

User339333
Tera Contributor

Hi,

 

I am trying to auto-populate the mobile phone (mobile_phone) number field on the sys_user table with a numeric variable from a catalog item via a workflow script. I see that the user's record is being updated but the mobile phone number is still blank. If I change my script to populate the Business phone (phone) field instead, it works fine. The Mobile phone field has the E164 formatting on it and doesn't seem to be working. I believe it's the type of field, but I'm not sure how to change the script to make it work. 

 

Here's my Run Script...

// Update User Profile with mobile number onSubmit.
var requestFor = current.variables.recepient;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', requestFor);
gr.query();
if(gr.next()) {

gr.mobile_phone = current.variables.provide_the_mobile_phone_number;  //If I change this to look at the phone field it works
gr.setWorkflow(false); // Turn off notifcations.
gr.update();

}

 

User339333_0-1702481578158.png

 

2 ACCEPTED SOLUTIONS

Brad Bowman
Kilo Patron
Kilo Patron

Out of the box the phone and mobile_phone fields are both the type of Phone Number, and both format a plain number string when entered through the UI.  In a Fix script I can set the value on a user record to either a plain number string or a E164-formatted string on either field, and it shows the expected number (formatted or not) when I view the user record.  Is the mobile_phone field in your instance a different Type?  What is the value of the (string?) variable that the script is trying to populate?

View solution in original post

If I'm picking up what you're putting down, I changed the mobile_phone field on the sys_user table in my PDI from Phone Number (as opposed to Phone Number (Unused), the plain one, deprecated or not, still works) to Phone Number (E164).  To populate this field via script requires + with the country code, so trying to set it to '18008675309' results in a blank field/no change, but '+18008675309' works. 

View solution in original post

10 REPLIES 10

If I'm picking up what you're putting down, I changed the mobile_phone field on the sys_user table in my PDI from Phone Number (as opposed to Phone Number (Unused), the plain one, deprecated or not, still works) to Phone Number (E164).  To populate this field via script requires + with the country code, so trying to set it to '18008675309' results in a blank field/no change, but '+18008675309' works. 

Oh! okay I will try.

Brad that worked. Okay I'll make a few updates to my variable to ensure the end-user enters the data a format the system will accept. Thank you for sticking this out with me!!

You are welcome!

Can you share details on what was done?