need to display user email id based on user reference filed

praveen50
Tera Contributor

i have created one catalog item under that created two variable

 

1. add user its referring to sys_user table

2. email id -string name -need to auto populate based on selected user.

 

actually my requirement is to show instead of name I want to show email id in the add user variable or else based on user selection on add user variable need to auto populate on user email in email id variable  .PFA belwo screenshot.

 

can any one help me script

 

find_real_file.png

8 REPLIES 8

Dhananjay Pawar
Kilo Sage

Hi,

Write onChange catalog client script on user field.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var caller = g_form.getReference('user variable name', doAlert); // Change variable name

function doAlert(caller) {
    g_form.setValue('email variable name', caller.email); // Change variable name

}

}

 

Thanks,

Dhananjay.


In normal catalog item view below script is working
In service portal its is not working 
can you help me to written script include & call to script include in catalog client script.

Hi,

Can you change the UI type of client script to mobile/service portal and then check it once.

UI Types - 

1) Desktop - It will work only at client side

2)Mobile/ Service portal - Will work only on portal OR on mobile

3)All - it will work on both side(client and server)

Thanks,

Dhananjay.

Hello,

As per my knowledge getReference(() is not working on service portal. Have look the below code,

https://community.servicenow.com/community?id=community_question&sys_id=374e6eeddb866b0011762183ca96...

https://community.servicenow.com/community?id=community_question&sys_id=e1c143a9db98dbc01dcaf3231f96...

 

If answer is helpful please mark correct or helpful!

Thanks,

Pratiksha