Before going to far:
- What is happening when you use the debugger to step through the script.
- Could you show the script here.
Sure. It's a pretty short script...
Set Variable $id, Table::IDfield
If(GetValue(Get(TriggerTargetTabPanel), 1) = 1
Constrain found set (restore)
Go to Record [first]
Exit loop if Table::IDfield = $id
Go to next record
Set Variable $$YouAreHere to get(RecordNumber)
That's it. NB the Constrain is done in such a way as to guarantee that an $id record still exists post-constrain. I didn't bother typing in what happens for switching to other tabs since it's not relevant here.
If I switch to tab 1 with script debugger open, it runs through the script as expected. The Set Variable step at the end is just to make sure the script works. I switch tabs, the script runs, and before I step through that last Set Variable step, I can see that I am where I want to be. The variable is set, the script ends, the tab switches and the record jumps back to the record number that was showing before the script began executing.
Just for fun, I threw a button onto the layout which does nothing but go go record number $$YouAreHere. If I switch to tab 1 and then click the stupid button, I end up on the record I want. I just (obviously) don't want to have to hit an extra button once the tab switch is complete.
Edit to add: If I change the conditional to 1 (always true) and run the script manually (without changing tabs), when the script completes I am on the expected record.
1 of 1 people found this helpful
Well, OK, I found a way....
Name your tabs. I use t1, t2, etc.
Add a step to the end of the script that uses Go to Object to switch to the desired tab. (t & TriggerTargetTabPanel). Then, exit the script with result 0, which halts the (non-script) tab switch. That effectively turns the tab control into nothing but a button that runs your script.
I don't know whether I'm working around a bug or a feature here, but if anyone else has this problem, there you go...