Codeus Posted June 13, 2008 Posted June 13, 2008 (edited) I needed a way to manually reorder portal records from time to time and to keep a sequential number with each record for export purposes. This example I created does this via a looping script which allows individual records to be moved up and down the sort order and also delete records from anyplace in the sequence and have the remaining records automatically resequenced. I am not sure if it might get slow when dealing with large numbers of records but in my case there are unlikely to ever be more than a dozen or so. I am still a relative novice with FM so would be interested if there is a slicker / quicker / better way of doing this. Codeus ManuallyReorderPortalRecords.fp7.zip Edited June 13, 2008 by Guest Removed Forum Sample File Topic Info
comment Posted June 13, 2008 Posted June 13, 2008 I think this could be a lot "cheaper" (and faster) if you dealt only with the two records that need to be swapped, e.g. (after checking feasibility) ... # Go to Related Record [ “Child”; Show only related records ] Set Field [ Child::Rank; Child::Rank + Get ( ScriptParameter ) ] # Go to Record/Request/Page [ Get ( RecordNumber ) + Get ( ScriptParameter ) ] Set Field [ Child::Rank; Child::Rank - Get ( ScriptParameter ) ] # Commit Records/Requests Go to Layout [ original layout ] The script parameter is simply either 1 or -1. Of course, none of these methods will work if two users want to arrange the records in different orders. 1
Codeus Posted June 13, 2008 Author Posted June 13, 2008 Ahhh, thanks, yes that is much simpler, and can also be applied partially to how a record is deleted from mid-sequence, although a loop is still required to update any records further down the sequence. Thanks again, Codeus
comment Posted June 13, 2008 Posted June 13, 2008 a loop is still required to update any records further down the sequence. Or you could just replace field contents with serial numbers. There's another possible approach, that doesn't use sequential rank numbers. The default rank is simply ChildID, which automatically puts any new record at the bottom. This means you can create and delete records in any way, and the rank order is preserved. However, when re-ordering the records, you must exchange the two rank numbers: ... # GO TO SOURCE Go to Related Record [ “Child”; Show only related records ] Set Variable [$sourceRank; Child::Child::Rank] # # GO TO TARGET Go to Record/Request/Page [ Get ( RecordNumber ) + Get ( ScriptParameter ) ] Set Variable [$targetRank; Child::Child::Rank] Set Field [ Child::Rank; $sourceRank ] # # RETURN TO SOURCE Go to Record/Request/Page [ Get ( RecordNumber ) - Get ( ScriptParameter ) ] Set Field [ Child::Rank; $targetRank ] ...
Codeus Posted June 14, 2008 Author Posted June 14, 2008 That's a very neat idea. I need the numbers to be sequential for my export so will replace with serial numbers as you suggested. Thanks again.
comment Posted June 14, 2008 Posted June 14, 2008 I need the numbers to be sequential for my export A summary field could take care of that.
Codeus Posted June 15, 2008 Author Posted June 15, 2008 Thanks comment, That was very helpful, revised version attached. ManuallyReorderPortalRecords_v2.fp7.zip
comment Posted June 15, 2008 Posted June 15, 2008 But where are the dividends of simplification (no relationship, records created and deleted freely, etc.)? MovePortalRow.fp7.zip 1
Codeus Posted June 16, 2008 Author Posted June 16, 2008 That is very slick, and really shows up how clunky my original solution was. One thing I don't understand is how you set the Child::Rank field to static text for the portal arrows? Am I missing something obvious here? It's a really nice way to stop the buttons appearing on the blank row at the bottom while still allowing direct related-record creation.
Codeus Posted June 16, 2008 Author Posted June 16, 2008 One thing I don't understand is how you set the Child::Rank field to static text for the portal arrows? Ah, I see it is boolean number formatting - very neat, should have looked for a few minutes longer before I posted Thanks again.
Newbies bright_guy Posted December 10, 2010 Newbies Posted December 10, 2010 Ah, I see it is boolean number formatting - very neat, should have looked for a few minutes longer before I posted : Just so you know, the Rank field is (re)set in the "Swap Adjacent Rows" script.
Newbies hsmkitty Posted September 27, 2013 Newbies Posted September 27, 2013 I have tried to apply this to my database and am having trouble figuring out why the "Rank" field is not staying static. The technique seems to work (for a while anyway) but eventually the "Rank" fields start changing to the same number which locks up the script. Any idea what I'm doing wrong? I notice the previous post said something about changing the field setting to a boolean, but I am a newbie and do not know what they mean as far as changing the number formatting to boolean. Thanks!
Newbies hsmkitty Posted September 27, 2013 Newbies Posted September 27, 2013 DOH!!! Okay, nevermind....like Codeus, I see what you mean. I didn't see that the up/down buttons were grouped with a copy of the "rank" field on the layout. Just an FYI for anyone else who has this issue, the "Boolean" mentioned in an earlier post is on the Data tab in the inspector.
Recommended Posts
This topic is 4131 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now