Documentation states that the function returns zero when no portal is selected.
Try moving line 10 (go to object) down AFTER your find. Although line 13 (show all) negates your find in line 12, so not sure what you're trying to do there.
Basically by performing a find or showing all records, you are unselecting the portal, so nothing else you're trying to do evaluates properly. Moving line 10 down to line 14 should make some of it work.
Also, line 20 shouldn't be there. If you're trying to save (commit) the record, you should be doing that before you do anything you have written in the rest of this script.
What I am after, (and I understand why you don't understand by looking at my code) is to move the portal scroll bar down so that the current record is revealed. (This is what I was trying to do with the FIND and GOTO PORTALRow etc...).
The "X" portal (TOC of Members named MembersPortal) has hundreds of records. When I enter a new record and enter the last name, some code runs which has a COMMIT RECORD in it., So, if the last name is WILSON, for example, that new record will fall near the bottom and out of sight of the portal. All I want is for the portal scroll bar to move down along with the insertion of the new, WILSON record so that Wilson is visible.
Move Go To OBJECT AFTER the find? If I am trying to find the PK in MembersPortal, don't I need to GO TO OBJECT first and then FIND on the MEMBERSPORTAL table. Otherwise I am finding on MEMBERS....?
The use of SHOW all is my 'lame' attempt to, after a successful find and to avoid 1 of 1 records found, to show ALL records with target record highlighted.
Thanks for the reply.
no, a perform find script step is always performed outside of the portal.
What you probably need to do is:
Set Variable [ $matchingkey ; the key you are looking for ]
Go To Object (portal)
Go To Portal Row [ first ]
Exit Loop If [ table::primaryKey = $matchingkey ]
Go To Portal Row [ Next ; exit after last ] //exit after last if no match
You might need to scrap a large portion of that script and start over using this method.
you're still doing kind of bizarre stuff in your script.
Lines 10/12/14 are not needed, move line 13 above line 11 and it will work exactly the same way.
Why the commits on lines 3 & 7? you're not editing data at all here?
Lines 16-19 undo what you just did inside of the loop. no reason for them.
Line 6 should be above line 4.
If you want to get the active portal number from what you found in the loop, then line 5 has to be AFTER the loop is complete. But since you're already navigating to the portal row inside of the loop, there is no reason to use any of your $portalrow steps.
Where you have it now, $portalrow is probably returning zero, because you've gone to the portal itself, but not any row in the portal. If you place line 5 after line 8, then it will return 1. If you put it inside the loop, then it should increment up with each row number, 2,3,4,5 etc...
Do you have script debugger and data viewer open so you can run this script and step through it to see how these variables evaluate, and how these script steps work?
I got it to work. Just used your looping routine and put it in a script that was called whenever I had to add, delete or navigate a record.
I was thinking that there would be some FM setting, or function that I could invoke that would move the portal scroll bar; but there apparently is not. Maybe in FM 15...
Thanks for all the help.