Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Moving Portal Rows Up and Down


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

Recommended Posts

Posted

I have a portal that displays a list of documents and has 2 buttons: one to move a document up one row, and another to move a doc downone row. The portal is sorted based on Sequential # (number field). The scripts work for a number of moves and then one or the other screws up, but not always the same one. I can't figure out why.

Could the portal rows get changed (resorted) by FM before the script terminates so that I'm not on the row I think I am? Does anyone see what I'm doing wrong?

_iloc and _ipos are global number fields.

Move Sale Document Up:

Set Field [ _iloc, Status( CurrentPortalRow) ]

If [ _iloc = 1 ]

Halt Script

End If

Go to Portal Row [ _iloc ]

[ By Field Value... ]

Set Field [ Sale Documents Portal::Sequential #, Sale Documents Portal::Sequential # - 1 ]

Exit Record/Request

Set Field [ _iloc, _iloc - 1 ]

Go to Portal Row [ _iloc ]

[ By Field Value... ]

Set Field [ Sale Documents Portal::Sequential #, Sale Documents Portal::Sequential # + 1 ]

Exit Record/Request

Go to Portal Row [ _iloc ]

[ By Field Value..., Select entire contents ]

Move Sale Document Down:

Set Field [ _iloc, Status( CurrentPortalRow) ]

Go to Portal Row [ Last, Select entire contents ]

Set Field [ _ipos, Status( CurrentPortalRow) ]

If [ _iloc >= _ipos ]

Halt Script

End If

Go to Portal Row [ _iloc ]

[ By Field Value... ]

Set Field [ Sale Documents Portal::Sequential #, Sale Documents Portal::Sequential # + 1 ]

Exit Record/Request

Set Field [ _iloc, _iloc + 1 ]

Go to Portal Row [ _iloc ]

[ By Field Value... ]

Set Field [ Sale Documents Portal::Sequential #, Sale Documents Portal::Sequential # - 1 ]

Exit Record/Request

Go to Portal Row [ _iloc ]

[ By Field Value..., Select entire contents ]

Posted

Sure, I think I see your problem... Look closely at the script, for a moment, lets say, for instance you are moving item 4 to be item 3, and thus item 3 to be item 4:

First you say, basically, Go To Item 4

Then, Change Item 4 to be Item 3

Then, Go to Item 3 - BUT! You have two seperate records that have a sequence of 3 for that moment - the old 3 and the new 3. This is a big problem, because that means FMaker is going to grab whatever item 3 it decides should be 3rd in the sort, usually whatever one was created earlier. A better solution might be, to make item 4 into item 3.5, then make item 3 item 4 then make item 3.5 item3.

Make sense? This might not be the ONLY prob, but its definitely one I see.

This topic is 8150 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.