I believe if you put a commit records script step in there, the script will not go anywhere next.
Unfortunately I'd already got one there:
Enter Find Mode [ ]
Set Field [ Patient::__uuID; Global::gSelectPatientID ]
Perform Find [ ]
Ah. I'm sorry. I misread your post.
You need to specifically go back to the tab you were on at the beginning of the find script.
I would name each tab in the Inspector ( the Position menu). At the end of this script, I'd set a script step: Go To Object and pass in the name of the tab they were on before the search started.
To expand a little on Jeremy's suggestion: the idea is that your script somehow has to know which tab to return to. You could pass the current tab name as a script parameter, but IHMO it's simpler to capture the front tab when the user goes to it, rather than after the fact*.
1. A script trigger OnPanelSwitch on the tab object sets a variable called $$frontTab (or whatever) to Get(TriggerTargetPanel)**
2. Your script ends with Go to Object[$$frontTab]
*GetLayoutObjectAttribute is messy.
**Actually GetValue(Get(TriggerTargetPanel); 2) -- the value is stored as a list of the panel number and name.
Thank you both. I tried the latter and on brief trial didn't get it working. However, simply having 'Go to object' after I'd named the tab, worked on its own. Is there anything dodgy in doing this? I can still move around the tabs as normal.
Your Go to Object implementation will always go back to the same tab, regardless of what tab the user was last on.
The previous suggestions would capture the the name of the front tab so you can go back to any tab the user was on before.
Your script may work in your scenario at the moment, but you might need to change it in the future.
Go To Object can be hard coded or you can pass in the name of the object as a parameter. If I'm on tab 2 and I do something, it could be logical that I'd want to return to tab 2, so I'd just put my script step in saying Go To Object[ 2 ].
Either method works just fine, I feel. I'd use the Get(TriggerTargetPanel) When I want to capture what panel the user is on for another purpose such as showing them instructions or whatever. But it certainly can be used to go back to the same panel from where they came.
Name each tab in your tab control. If you have multiple tab controls on a layout, make sure each name is unique. Let's assume you have only one tab control, 5 tabs.
Your user is on the 3rd tab. You want to have FM do something via script, and return the user back to where he started. So by naming the tabs Tab1, Tab2, Tab3, Tab4, Tab5, you've created individual objects to which you can go.
What Tom Fitch is saying is it might be a good idea to auto-set a variable, maybe $$CurrentTab, when a user goes to any tab other than the front one. A user clicks on the third tab. You have a script trigger OnObjectEnter, and it basically just does the following:
Set Variable $$CurrentTab = GetValue ( Get ( TriggerTargetPanel ) ; 2 )
That will make $$CurrentTab contain "Tab3". Once you name a tab panel, Filemaker stores that as a return-delimited list, like:
So now that you have stored the value of the tab on which your user is...you can script something that will use:
Go to Object $$CurrentTab.
I can see how that would be useful when wanting to automatically return to a tab after a foray to another one. However, my script is only on 1 tab and I just need it to not cause me to move to the default front tab each time the script is triggered. A simple go to object step at then end of the script seems to achieve this.
But thank you for the info; it could be useful in the future.
tays01s Your solution is fine. What I and others suggested assumed that you needed a dynamic way to return to an arbitrary tab. If all you need is a way to return to a specific tab, then I agree, keep it simple.