Try checking whether
Get ( RecordNumber ) < Get ( FoundCount )
If so, you're already on the last record. If you put your existing script steps inside an "If" and this function, you won't run the script again when you're already on the last record.
As an added thought: Do you have to actually go to the last record, or do you just need a value from the last record? If the latter, you may want to consider GetNthRecord ( MyField ; Get ( FoundCount ) ), and then not change records at all.
If $$ScriptCt = 1
Set Variable $$ScriptCt = 1
Go to Layout [ L201 RESULTS_ Data Entry (Results_Entry) ]
Go to Record/Request/Page [ Last ]
Go to Object [ Object Name: "Retrieve Popover" ]
Set Variable $$ScriptCt = ""
Thanks for the help, all three approaches worked great, I went with the If statement, even though I don't actually need to go to the last record, I would have hadto create 7 global fields with the GetNthRecord, there are actually 7 values I need to retrieve. I had forgotten about the GetNthRecord, good reminder.
I ran the script on the popover layout OnObjectEnter and when I tired it on the popover button it wouldn't run, should it run on the button?
You have to set it to goto the popover itself. The button and popover are treated as separate objects.
It is working on the popover. I was more curious shouldn't it also work if attached to the button itself?
Based on my understanding (and perhaps some assumptions) it won't work on the button since it is making the popover the active object rather than itself.
Again this is more out of curiosity, it seems that if the set trigger,OnObjectEnter, is on the button the script should be executed when I click on the popover button because it is the active object for a split second. In my case the script would go to the last record when the button is clicked, so when the popover layout opens I should already be on the last record, not needing to run a script to go to the last record from the layout? Just trying to understand how this works for future reference.
Perhaps a reasonable guess; but no.
The button is never the active object.
Unless you have set the button to be in the tab order; and you have tabbed into it.
This is by design. Imagine that you have a field, and the cursor is in it, and you have a button that operates on the contents of the active field.
That makes sense, thanks for the insight.