Ordering GlideRecord with null values

Michiel Meijler
Tera Contributor

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

1 ACCEPTED SOLUTION

You need to split these into 2 gliderecords. One with null and one without.


View solution in original post

12 REPLIES 12

I meant something like this



find_real_file.png


-Anurag

Copy query will not include sorting if this was what you meant


.temp.png


David Hubbard
Tera Guru

Ok - this is a little old - but I have the same requirement.  Although I needed to be able to page through the record, using "chooseWindow".

 

I ended up creating a "date_field_sort" field and using a Business Rule (Insert, Update) to either put the value of "date_field" or a high date value into the "sort" field.