Sorting by Server RecordID

Is there a way to sort by the info(“serverrecordid”) value? If not, what is the best way to have the ability to restore a databases records in the order they were added?

Have a field with a timestamp for each record.

You can add a temporary integer field and fill it with the serverrecordid, sort on that and then delete the temporary field. Here is the example code I tested that hides all the action until the final sort is ended and the temporary field is removed:

insertfield "tempID"
fieldtype "Integer"
formulafill info("serverrecordid")

Add a field, fill it with the formula


and sort it.

Panorama X has an undocumented statement named SortServerRecordID. This is used by Panorama X Server. Of course that isn’t out quite yet, but according to source control this statement was written in November 2017, so it is already included in the currently released version of Panorama X. So you should be able to sort by record id with one simple statement:


Thank you to all, as many have said, everyone on here are incredibly helpful. Jim, is there a way to reset the server recordid? Will the server id record ever change? I just read that in a Panorama X Server environment it will change when a file is re-shared. Is this still true? Also, what is info(“serverrecordts”)? A time stamp?

Yes, there is. Don’t ever do that! In fact, I’m not going to tell you how to do it, but if you ever figure it out, don’t use it.

Yes, the id numbers can change every time there is a new sharing generation. So the info(“serverrecordid”) is NOT a good long term method for identifying a record. If you need that, you’ll have to create one some other way, for example auto numbering or using info(“guid”) or timestampstr(( when you create the record.

Sort of. Values that are larger indicate records that have been modified more recently. But it’s not based on a clock or calendar. If record X has a TS value one greater than record Y has, it means that X was modified more recently, but probably not 1 second later. It could be a minute later, an hour, or any amount of time. (If the TS value was actually time based, synchronization wouldn’t work if different computers accessing the database were in different time zones.)

The best bet is probably to not use these values at all. They are for the internal use of Panorama Server, and most likely aren’t going to be of any use for your applications.

This question assumes that records are only added to the database, never inserted. If records have been inserted in the middle, there is really no general way to restore the order. When I want to do that, I will add a sequence field, and fill it with a sequence (1, 2, 3) just before I sort the database. Then I can always sort it back into the original sequence. But for this to work, you generally have to rebuild the sequence field every time before you sort to a different order.