Referencing the sys_user email address

Jason Stephens
Kilo Guru

How would I create a reference variable that is referencing the email address from the sys_user field?

17 REPLIES 17

Hi Jason,



I have the same question of pulling email address instead of name on referencing the field.



Can you let me know the solution?



Many thanks


gbernie
Kilo Expert

Hi Jason,


You can also use either a client script or catalog client script to update onLoad or onChange so long as you have a sys_user field like requested_for



Here is an example of an onLoad Catalog Client Script we have


function onLoad() {


   


    if ('email' == '' && requested_for != '') {


          g_form.setValue('email', '');


          return;


    }



    if (!g_form.getControl('email'))


          return;



    var caller = g_form.getReference('requested_for', setEmail);


}



function setEmail(caller) {


    if (caller)


//Get and then set the email address from the sys_user record


            g_form.setValue('email', caller.email_address);


}


Thanks Gareth.



I tried to follow the referencing field from ServiceNow wiki for the same question, but it did not work as the wiki suggested.



Do you know if the referencing field deliver the same outcome?



If yes, can you let me know how in details?



Many thanks for your help


Hi Eddie,


can you add a screen shot of what you are trying to achieve.


Hi Gareth,



I want our user to select the Caller Name as the screenshot which will populate the Caller's email address in the Email field. With the option, user can either choose from the email suggestion or type-in manually.



I try to reference the Email field with the setting as the second screenshot. However, it does not work as I expect. One attempt, it shows the email suggestion with the caller name, when I select it, it only populate the caller name instead of email address.



Can you please help?



Many thanks


Email.pngEmail-Dictionary Entry.png