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 populate reference variable value on form from default value in variable?

shubham_sagare
Giga Contributor

I want "what is your department" to be populated when "who is requested for?" is selected.

"what is your department" is a reference field .

"who is requested for?" is a text field. In default value I have used "who is requested for?"

Can anyone please suggest what should I write in default value for "what is your department" variable, so that it should populate when the form loads

 

shubham_sagare_0-1712145487813.png

I tried by using, but none of them worked, I am getting the value as blank as attached in screenshot:

1.javascript:gs.getUser().getRecord().getDisplayValue('department');  ( department is backend name for "what is your department")

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

3. 

javascript:var dept=gs.getUser().getDepartmentID();if(dept)dept;

 

 

1 REPLY 1

Vishwa Pandya19
Mega Sage

Hi Shubham,

 

You can use the auto-populate feature available OOB in ServiceNow.

Please refer below screen shots.

VishwaPandya3_0-1712205489186.png 

VishwaPandya3_3-1712205564509.png

 

 

If my answer helped you in any way please mark it as correct.