Populate mobile number of the caller

Sam198
Mega Guru

Hi all,

I need to autopopulate the mobile number field from the sys_user table on the catalog item:

find_real_file.png

I am using javascript:gs.getUser().getRecord().getDisplayValue("mobile_phone"); in the default value tab of the variable "Contact Number" to get this autopopulated, but it does not, any suggestions?

I do not need change this field through onChange or any Catalog client scripts as I am leaving this field open anyway for them to change the contact number if they want to (because for example: changed phone number but not updated on sys_user record).

Thanks.

 

 

1 ACCEPTED SOLUTION

there's a gs.getUser() method for it, so you could use the following directly in the default value of the field or variable:

javascript: var userPhone; var user = new GlideRecord('sys_user'); if (user.get(gs.getUserID())) {userPhone = user.phone}; userPhone;

View solution in original post

14 REPLIES 14

Try to default value code:

javascript:gs.getUser().getRecord().getDisplayValue("phone");

there's a gs.getUser() method for it, so you could use the following directly in the default value of the field or variable:

javascript: var userPhone; var user = new GlideRecord('sys_user'); if (user.get(gs.getUserID())) {userPhone = user.phone}; userPhone;

Hi RamS, 

javascript: var userPhone; var user = new GlideRecord('sys_user'); if (user.get(gs.getUserID())) {userPhone = user.phone}; userPhone;

above script works perfectly as per my requirement in the default value, just needed to change "user.phone" to my name "user.mobile_phone".

 

Thanks

nice Mr.Ram !

 

fyi,given you a helpful !!

Rahul Kumar17
Tera Guru

hi 

U can use  getReference();

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar