How to get ordering to work?

I have tried setting the value type in firebase connector to string, number, timestamp, and even any text, and still cannot get the get record collection flow function to return any records using both filter by user id and ordering by date. Remove the ordering and it gets the records fine, but new comments stay on top and sometimes pop up in the middle of new list. Using NOW("") to write the date to firebase and also tried the current datetime format. I have even tried setting the value type to number and writing dates as 1, 2, 3. Still can’t get the ordering to work. If I remove the filter and use only ordering, it works. But both filter and ordering will not work.

Has anybody been able to do this?

Somewhy this is an issue that has been present for a while. You could do a workaround by doing only the filtering in the get record collection flow and then in the set data variable flow you can do a formula binding with the ORDER(outputofcollection,, “orderdirection”) formula.

My workaround is to use timestamp() for all dates that might ever need sorting. Its always a number and requires no conversion. I´m not sorting by it but I am filter so I only see records with a timestamp from the most recent hour.

When you say use timestamp() do you mean set the value type of the field in the connector to timestamp and use formula timestamp to write time to database?

tried this and at least they are showing now, but whether i use desc or asc, the newer comments still show on top

I’ll check my setup later and will share here.

I use a numeric field and write timestamp() into it. I just find it a much easier way to store date / time fields. Its only really for display purposes that a date needs to be readable, and its easily converted to a readable form using DATETIME.

Okay, you also use firebase connector. I use the same.
So in the data schema I have a property that has the value type as “Date/time text (ISO 8601)”:

That is it. When I create the record I use the NOW() function without any quotation mark. This creates a Date/time text value.
When I get the “ticket-messages” I use a filter formula to get messages in connection to one specific support ticket:

Filter condition:

And then the set data variable flow:

In this case I needed to have the latest message at the bottom, to create a feeling like a chat. But for your use case it would be “desc”.

Final result in the built web-app is being ordered correctly:

Hope this helps. :pray:

I got your solution to work! I had to set the value type of the field to number and go back and change the other values in the database to all timestamps and it worked beautifully! I am so happy this has been an issue for a while now I know how to do it! Thank you. :blue_heart::blue_heart::blue_heart:

1 Like

I guess that you marked the wrong post as a solution then.