Client Script

Shrabanti
Tera Contributor

Hello Team
sys_user table have some uers who has two profile with same name one with normal user id like 123xxx and other profile is with hyphen userid like aba-234 

user are login servicenow with normal user id .
in a catalouge item one varible need to populate name of current login user which is associated with hyphen id
i wrote that scrip but not working 

var name= g_user.getFullName();
   alert(name);// showing name of login user
   var gr=new GlideRecord('sys_user');
   gr.getEncodedQuery('active=true^user_nameLIKE-');
   gr.addQuery('name',name);
   gr.query();
   if(gr.next()){
    g_form.setValue('owner_of_lz_groups_paa_account',gr.sys_id);
13 REPLIES 13

hello @Abhishek_Thakur 

i want to populate that second user profile with hyphen userid not that login user one

Hello Shrabanti,

Do you want to populate the hyphen user id in the name field for the current user who is accessing the catalog item?

Could you please elaborate more, so that I can help you in better way.

Shrabanti_0-1725785876472.png

for example aaron jones have two profile and he login in servicenow esc portal with CG8070  that id and he order one catalouge item 
in that catalouge item one varible is there which is list collector of sys_user table 

Shrabanti_1-1725786060190.png

this field need to populate with CG8070-B this id of that same user

means login user hypen profile(not that main profile by which he is login) need to auto popup

Hello @Shrabanti ,

I got it. here you need to write the script include and onchange client script to achieve this requirement. let me write it and give you back.

ok,thank you