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.

Set the Default value of Reference variable with the first value of the list

Sarah Austria
Tera Guru

I have a reference field "Assignment Group" from the sys_user_grmember table. I have filter this from reference qual with javascript: 'user=' + current.variables.requested_by;

However, I need to set the default value with the first value available from the list? How to do this? 

Can this be possible from the Default value field? Or do I need to write client script? If via client script? How? thanks.

 

find_real_file.png

1 ACCEPTED SOLUTION

Hi Sarah - You need to write a client script to set the value i.e Client Script + GlideAjax approach. You can query the records from the table and add additional logic to filter the record with setLimit(1) to only return one record in a response.

Reference:

https://community.servicenow.com/community?id=community_blog&sys_id=f8ccee25dbd0dbc01dcaf3231f961978

 

- Pradeep Sharma

View solution in original post

10 REPLIES 10

Pranav Bhagat
Kilo Sage
You can uncheck 'include none'

Include NONE is available when the variable type is a Lookup Select Box. I am using a Reference variable

Jaspal Singh
Mega Patron
Mega Patron

Hi Sarah,

 

Passing it in the Default value field should work. 

What does it mean? This below script did not work.

javascript:gs.getUser(current.variables.requested_by).getRecord().getDisplayValue('group');