Jump to content

Manually reorder portal records


Codeus

This topic is 3856 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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 by Guest
Removed Forum Sample File Topic Info
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ]

...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 years later...
  • 2 years later...
  • Newbies

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!

Link to comment
Share on other sites

  • Newbies

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.

Link to comment
Share on other sites

This topic is 3856 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.