The CreatorCon Call for Content is officially open! Get started here.

Auto Populate user's email on catalog item field

pathumh09586800
Mega Contributor

I’m creating a Service Catalog item and I have a variable to capture the requester’s email. How can I automatically populate this variable with the logged-in user’s email when the form loads?

19 REPLIES 19

@pathumh09586800  and @T_Mia , Navigate to the catalog item > email variable > related tab > Default value > javascript:gs.getUserID().getUserEmail(); > save and check

 

If this solution helped you Please Mark this solution as accepted and helpful as it will be helpful for other users as well.
Best Regards.
Saurabh V.

@pathumh09586800 , @T_Mia , Have you gave it a try? Where are you stuck now?

 

If this solution helped you Please Mark this solution as accepted and helpful as it will be helpful for other users as well.
Best Regards.
Saurabh V.

 

T_Mia
Tera Contributor

Hi Saurabh, thank you for following up. Unfortunately the code you provided didn't work for me. However,  advised on a very simple way and it worked for me. 

 

https://www.servicenow.com/community/developer-articles/auto-populate-a-variable-based-on-a-referenc...

 

T Mia

I used this, it works, thank you

 

 

@pathumh09586800 

it should be in your email address variable

If you want the Email address to change on selecting user then you can use Auto populate feature

Auto-populate a variable based on a reference type variable (Utah) 

You can also auto populate the reference variable using this in the default value so that it populates logged in user

javascript: gs.getUserID();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader