function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
luckymeluckyme 

Order by Name issue

I have some custom objects for which I set the Name field to be auto number and I want to be able to get the rows in the same order that I wrote them.

 

But to my surprise when I do 'select ... from ... order by Name', it is not working as I expected. For example, row 99 will come after row 100 -- the reason I think is it is ordering as strings not numbers.

 

Note that order by CreatedDate does not work because some rows may have the same value.

 

Of course I do not want to create a number field and maintain a counter myself.

 

Anyone knows how to get around this issue?

 

mtbclimbermtbclimber

Yeah, custom object name is always a string.  Looks like we opened up sortability on ID fields, perhaps with version 18.0 (haven't been able to confirm). You can try ordering by ID.

nickname142857nickname142857

Thanks, Andrew.