Courtesy of Phil:
Include in your relationship for that portal a cartesian join of some text field, like:
gTextFile X AnyOldField
and in the save script, set the gTextField to itself.
I have ID = ID relationship. It works. On my save script the sorting works perfectly also. But, I need the portal rows to be sorted BEFORE save.
Sorry, don't understand. How can the file sort something based on data it hasn't seen yet? You could trigger a re-sort after you create each row with a ScriptTrigger, presumably.
Yes, I did. I triggered re-sort script, by using Refresh Windows, Flush cashed join result; Flush external data, when a new line has been entered. But the commit is not trigged, because I have a web viewer on the background which prevent the parent and portal record save automatically and I can revert it.
You're in a bit of a catch 22 here. You need to commit the record so that the sort can take place, but can't commit the record without also committing the parent record and then you can't simply revert the record to undo the data entry changes.
I think you'll need to redesign your layout, tables, relationships, etc so that you have a way to revert your data without using FileMaker's built in Revert option.
You can capture the original value of fields in global fields or variables when you enter the field to change it.
You can design a layout based on global fields and use a "save" script to copy the data from the global fields into a new or existing record.
I see and thanks.It comes to my mind for two ways to implement own revert.1. Use global variables and/or fields. It should not be problem to use global variables and/or fields for general fields. But, nothing come to my mind for the portal row implementation. Any suggestion for portal rows info?2. By duplicating parent and children records(portal row) with temporary primary key to link both temporary parent and temporary children together for editing. When Save command is clicked, copy all temporary parent and temporary children to original record. When Revert command is clicked, discard temporary records.Comments are very welcomed.
I can't really suggest much without knowing more about the portal. What is the current relationship that you have? You can set up a relationship where the field on the parent side is a global field, but you still have the issue of reverting records with the portal's records.