Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get the value from referenced field and display it as default value to the variable of record producer?

s_s
Giga Contributor

Hello community.

I would like to get the value from referenced field and display it as default value to the variable of record producer.

For example, I set default value to variable of record producer as below to get the 'name' value from user table .

find_real_file.png

And then I can confirm that the variable has 'name' value as default value on the portal.

find_real_file.png

 

However, I can't get the value 'department'.

Even if the same setting is made(gs.getUser().getRecord().getValue('department')), the department value cannot be obtained.

I appreciate if you could answer it.

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

try now. 

 

javascript:gs.getUser().getRecord().getDisplayValue('department')

View solution in original post

9 REPLIES 9

Allen Andreas
Tera Patron

Hi,

Can you try:

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

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you for your reply.

I tried it, but I can get only ID.

find_real_file.png

That's correct...so if you know that's a department field? Then make it a reference field to the departments? That way when you set the default value using the method I gave you, it nets you a department?


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Sorry for lack of explanation.

I would like to get the department value('Customer Support') of the user who is currently logged into the portal.

so, I mean I would like to get not ID but name of Department.

find_real_file.png