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

svirkar420
Tera Guru

Hi @pathumh09586800 , you can use this script in the default value of the variable in which you want to populate the email of the logged in user. 

Code : javascript:gs.getUserID().getEmail();

Write this code in the default value related list of the Email variable. This will work definitely.

 

Make sure to mark the solution as Accepted and Helpful as it will be helpful for other users as well.

Best Regards,

Saurabh V.

Hi @pathumh09586800 , Hope you are doing well, Have you tried my given solution in your instance?

Also, you can accept more than one answer as solution.

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

TejasLogicX_11
Mega Contributor

Hi @pathumh09586800  ,

to auto populate the user email  we can set its default value using JavaScript code:

1) open variable form and set its default value

 

javascript: gs.getUser().getEmail();

TejasLogicX_11_0-1758153621936.png

 check output on catalog item form.

TejasLogicX_11_1-1758153706600.png

 

aslo

we can write onLoad client script to set email field value.

 

 

If my response/article helped you, please mark it as the correct answer and close the thread — this helps other readers in the community.

Tejas Pravin Adhalrao
🚀 ServiceNow Developer | 🏆 SN Hackathon Finalist | 💡 Community Contributor
📧 Email: tejas.adhalrao11@gmail.com
🔗 LinkedIn: linkedin.com/in/tejas1018

 

 

 

     

 

thank you

TejasLogicX_11
Mega Contributor

Hi @pathumh09586800  ,

to auto populate the user email  we can set its default value using JavaScript code:

1) open variable form and set its default value

 

 

javascript: gs.getUser().getEmail();

 

TejasLogicX_11_0-1758153621936.png

 check output on catalog item form.

TejasLogicX_11_1-1758153706600.png

 

aslo

we can write onLoad client script to set email field value.

 

 

If my response/article helped you, please mark it as the correct answer and close the thread — this helps other readers in the community.

Regards,

Tejas 
🚀 ServiceNow Developer | 🏆 SN Hackathon Finalist | 💡 Community Contributor
📧 Email: tejas.adhalrao11@gmail.com
🔗 LinkedIn: linkedin.com/in/tejas1018