- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 11:16 PM
Hi,
I have created a relationship for my workspace and I want the values to get sorted in ascending order of 2 columns - segment_id and rail_route_unique_id but the script is only working for one column at once and not both columns together. Is there any other way to write the columns so both of them work together?
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('rail_request_number', parent.sys_id);
current.orderBy('segment_id');
current.orderBy('route_unique_id');
})(current, parent);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 05:16 AM
you can orderBy only 1 field and not more than 1 using current object, this is supported in GlideRecord query though
This you can verify when you visit any table list
If you order by Created then you cannot order on another field
This is platform behavior.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:59 AM
You are using the correct syntax/convention per SN documentation
Maybe this is a workspace limitation? Does the sort work by each column when only one is listed, or listed first? If not, there is an issue with one of the column names or it just can't be sorted by that column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 05:16 AM
you can orderBy only 1 field and not more than 1 using current object, this is supported in GlideRecord query though
This you can verify when you visit any table list
If you order by Created then you cannot order on another field
This is platform behavior.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader