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

Anish kumar
Kilo Guru

Just write an on load client script,

 

function onLoad() {
//Type appropriate comment here, and begin script below
var user = g_user.getFullName();

var date1 = new Date();

g_form.setValue("current_user",user);
g_form.setValue("time",date1);
}

 

OutPut will be

find_real_file.png

 

Kindly mark it correct and helpful if it solves your issue.

 

Thanks and Regards,

Anish Kumar