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

Sarah Austria
Giga 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

Hi,

In that case as already mentioned you need to use GlideAjax and Script Include

Note: Ensure you use setLimit(1) and use orderBy('name') in your query with name column

refer link below for GlideAjax example

Client script glideajax

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader