Sys_id to string value.

charmon
Kilo Contributor

I'm new to service now administration so please bare with me. I'm building a form and I need a few fields to autofill the information and its returning the user name as the sys_id not the string value. any help would be greatly appreciated

 

function onChange(control, oldValue, newValue) {

    var name = g_form.getReference('application_name');

    g_form.setValue('appowner', name.u_appowner);

}

 

the appowner field is populating the correct users sys_id but I need it as the actual name. Thank you in advance.

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi Chad,



if appowner is a reference field to the sys_user field then it will work as expected, else you will have to extract the user name from this name.u_appowner in the same was as you extracted u_appowner from application_name, ie using getReference.



a better approach will be   that you pass application_name to a script include using glideajax and there you can directly extract the u_appowner and get the display value of u_appowner by using .getDisplayValue().


-Anurag

View solution in original post

8 REPLIES 8

salvadormarchan
Kilo Guru

Try this:


var name = g_form.getReference('application_name').fieldname;




...where 'fieldname' is the field name of the User table where the name of the person is stored.


also, 'name' is widely used...I recommend 'myName' instead.




OR....try this:




var myName = g_form.getDisplayValue('application_name');


g_form.setValue('appowner', myName );




Thanks!  I used the below code to copy list collector values to a text box in order to include the variable in my flow designer email. 

var myName = g_form.getDisplayValue('application_name');

g_form.setValue('appowner', myName );

Anurag Tripathi
Mega Patron
Mega Patron

Hi Chad,



if appowner is a reference field to the sys_user field then it will work as expected, else you will have to extract the user name from this name.u_appowner in the same was as you extracted u_appowner from application_name, ie using getReference.



a better approach will be   that you pass application_name to a script include using glideajax and there you can directly extract the u_appowner and get the display value of u_appowner by using .getDisplayValue().


-Anurag

can you please provide us example with some code? i am experiencing similar issue