
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 04:58 AM
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.
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 11:08 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 05:13 AM
it will show the restricted values but you cannot set the default value directly as the 1st value from list
When you use default value in variable it would directly show only 1 value
How are you determining which group is the 1st?
Is it based on the sorting of name? if yes then you can just use orderBy in the variable attributes
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 05:17 AM
yes, it is based on the sorting of name (alphabetically). But how to do that? Can I just put it in the default value field? or I need client script? Not sure how to script it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 05:29 AM
Hi,
I assume this is for service catalog variable so you can add this in the attributes section of that variable
ref_ac_order_by=name
to be updated in variable attributes
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=name,ref_ac_columns_search=true,ref_ac_order_by=name
Note: this will just sort but won't set the value directly
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 05:40 AM
I see, thanks. But what I need is to set the default value with the first value on the list that is sorted alphabetically.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 11:08 AM
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