Virtual agent - user object

Eli Guttman
Tera Guru

Hi,

Is there an easy way to access the current user object and quickly get the first name, last name, full name, email?

Does gs.getUser suppose to work on virtual agent?

 

Thank you!

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Elig,

You can use vaInouts object to get all the info required.

   return gs.getMessage('hi there {0}', [vaInputs.user.first_name]);

You can get other values similarly by dot walking. Let me know if you have anymore questions.

 

find_real_file.png

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Cheers,

Hardit Singh

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

Hi Elig,

You can use vaInouts object to get all the info required.

   return gs.getMessage('hi there {0}', [vaInputs.user.first_name]);

You can get other values similarly by dot walking. Let me know if you have anymore questions.

 

find_real_file.png

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Cheers,

Hardit Singh

Thank you.

 

using the vaInputs.user i can reach to any field of the user, even custom fields.

 

for example: vaInputs.user.u_level2_manager.getDisplayValue(); 

u_level2_manager is a custom reference field.

 

Thanks again!

Mark Roethof
Tera Patron
Tera Patron

Hi there,

For first_name, last_name, email, phone, title Hardit is correct. Not everything from the user record will be available thru this, for example date_format will not work.

So it is vaInputs.user.something. This is different from what is described in the docs (which actually does not work!). The docs mention just using vaInputs.first_name (https://docs.servicenow.com/bundle/newyork-performance-analytics-and-reporting/page/administer/virtu...).

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

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn