Getting user email based on selected user in another field on a form

Philip Conforzi
Tera Contributor

Hello everyone!

 

I seem to have run into a development issue with my work, specifically with the creation of an onLoad Catalog Client Script for my form.

 

I currently have a dropdown field where you select the name of any user within the organization that is prepopulated with the name of the logged in user when the form loads.

 

I want another field within the form (user email field) to get the user email automatically when the form loads based on the user that is in the user dropdown field. I'm having issues with this.

 

Are there any ideas on solutions? Please see my code attached.

 

Thanks!

 

 

 

 

5 REPLIES 5

AshishKM
Kilo Patron
Kilo Patron

Hi @Philip Conforzi,

Please check if the field definition page has "Auto-populate" option then you can just give the reference of user variable and select the Email in dot walk field. User field should be reference type.

 

Sample form :

AshishKMishra_0-1702431310816.png

 

-Thanks,

AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

SLK Gupta
Tera Guru

Hi @Philip Conforzi ,

 

As you are working with a catalog item, and you want to auto populate the variables based on the loggedin user (which you might select as requested for or any other variable). 

For Autopopulating the variables you are not required write any code.
From ServiceNow Utah release we have an option called Autopopulate on the variables form, using it you can autopopulate the values into variables as required @Philip Conforzi.

 

Naviagte to your catalog item and open the variable which you autopopulate the data,

SLKGupta_0-1702431355241.png

Seelect the dependent question and give the dot walk path for it and its completed @Philip Conforzi .

Try this No-Code approach once @Philip Conforzi , It might help you in assisting your requiremnt.

If my response helps you in any way please mark my response as helpful and accepted solution @Philip Conforzi .

 

Thanks & Regards,

S. Lakshmikanth Gupta.

Hey thanks for your reply!

 

This is actually a very interesting solution. unfortunately, the field I need to reference is not coming up as an option within the "Dependent question" field.

Hi @Philip Conforzi ,

 

Can you please provide more information about the fields you are having and the fields were you want to auto populate the data.(from which field you want to populate the data as well)

if i have that data, i will try to provide better assistance to you @Philip Conforzi 

Thanks & Regards,

S. lakshmikanth Gupta.