
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 02:53 AM
Hi,
I need to order a list of tasks on a date field in Ascending order.
By using the orderBy('date_field') the the tasks without a value for the date_field, will be ordered on top. I want to have these tasks at the end of my resultset.
Anyone for a solution?
Michiel Meijler
ServiceNow Developing Consultant
Odysseus Group
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 05:07 AM
You need to split these into 2 gliderecords. One with null and one without.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 03:54 AM
Hi Michiel,
As you are mentioning you can get the records of those records with no date value at the top using .orderBy('field'); , can you try using .orderByDesc('field name'.
Read GlideRecord - ServiceNow Wiki for more info.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 05:05 AM
Hi Sharique,
Thanks but ordering descending does not help. The records with null values will show at the end, but the other records are ordered incorrectly in that case.
What I need is a way to order first on valid dates in ascending order, then the records with null valued dates.
Regards,
Michiel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 05:07 AM
You need to split these into 2 gliderecords. One with null and one without.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 05:08 AM
Exactly kalaiarasam,, i was about to type the same.