Change sort of a portal
Is it possible to have a script change the sort order of a portal?
No, but there are ways to fake it.
Layouts that are identical in every way except for the portal's specified sort order is one way. (Buttons to change the sort order simply switch the layout.)
If your portal only displays small numbers of records there are ways to update a "sort" field in all the related records so that the records display in a different order. This approach can get really messy though if you are sharing the database over a network.
Each approach can have singificant draw backs, but if you really want the user to be able to change the portal's sort order...
A portal can be sorted on a field which is a Custom Function and set to recalculate when needed. The function can change its return value based on your selected method.
The program we have contains a record for user preferences. On this record is a field for the column of the portal the user prefers. The function returns the field that this column refers to. Clicking on the header of the portal runs a script that changes the value in the preference record, say from column1 to column2. And presto the portal will now sort on the new value the function is returning.
Can you show what the script would look like?
Retrieving data ...