How to display current logged in user name not userid

Nivedita
Mega Expert

Hello,

I want to populate username (fullname) not user id in opened by family.Can anyone help?

find_real_file.png

1 ACCEPTED SOLUTION

Nikhil Phalke
Kilo Guru

Hi,

 

You can do this using the default value.

write below code:

javascript:gs.getUserDisplayName()

 

Please mark Helpful and Correct based on Impact.

Regards

Nikhil

 

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

How are you populating that user id now? For example default value gs.getUserID()?

Have you tried gs.getUserDisplayName()?

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

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

You should use that:

//On change script on Requested for Field

var caller = g_form.getReference('requested_for',doAlert);

function doAlert(caller){
g_form.setValue('opened_by',caller.name); //opened by is variable name you can replace with you variabel name
}

This is if you want to add name of requsted for.

If you want to add name of loged in user

var name = g_user.firstName +' '+g_user.lastName

g_form.setValue('opened_by',name);

 

Thanks,
Ashutosh

Nikhil Phalke
Kilo Guru

Hi,

 

You can do this using the default value.

write below code:

javascript:gs.getUserDisplayName()

 

Please mark Helpful and Correct based on Impact.

Regards

Nikhil

 

Tnx for repeating exactly what I already mentioned.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn