I want to set current user (logged in) into String field

rojerio
Tera Contributor

I want to set current user (logged in) into String field and as well as in another field want to store time as per their time zone in service catalog. How should i do this?

Thanks. 

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You could use a default value in the Single Line Text variable, with javascript:gs.getUserDisplayName(); and javascript:gs.getUser().getTZ();

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You could use a default value in the Single Line Text variable, with javascript:gs.getUserDisplayName(); and javascript:gs.getUser().getTZ();

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Chander Bhusha1
Tera Guru

Hi Rojerio,

Go to the Default value of both the variables.

In the variable you will have the 

For user name 

javascript:gs.getUserDisplayName();

 

For timezone field:

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

 

Thanks,

CB

Pranav Bhagat
Kilo Sage

Try this

 

javascript:gs.getUserDisplayName();

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Pranav

Milind Gharte
Kilo Guru

Hi ,
Here is a link which will help you.

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

 

If it helps,Please mark Correct and 👍 Helpful.

Warm Regards,

Milind