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

Stefan Georgiev
Tera Guru

Hello @User339333 ,

after a bit of testing and digging into the documentation I found out that as long as you add the correct code at the beginning of your phone number it is working fine but if you try to set a value that does not contain a code or the code is wrong it is going to say that the update is done but the field is not updated. 

 

gr.mobile_phone = '+359 888888888' // Bulgaria is working fine, makes the update

gr.mobile_phone = '0888888888' // without code Bulgaria is NOT working fine, no update

 

Hope that this helps you!

If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.

All the Best,
Stefan

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?

You are absolutely right, OOB the Mobile and Business are the same. After investigating some more it seems someone made an update to the OOB Mobile phone field on the user table. I'm going to run with this route for the moment. Let's see if changing this type back would break anything. Thank you for the insight. I assumed since I did not see the typical "u_" for sure it was the OOB config, however that was not the case.  Thanks again.

So it turns out that Phone Number (E164) type is the new format and "Phone number" has been deprecated. Very odd that my new developer instance shows those field types. So I'm back to square one. To answer your question....the value is a US number preceded by a number 1 with no dashes or spaces. Any ideas? It works fine on our Business Phone field which is the regular number string.