There are a number of possible factors from an incorrectly designed script to script triggers being tripped upon exit or entry to the layout. If you have advanced, enable the script debugger and test. You can open a file with a limited access password and still use the debugger if you then enter the full access password when the debugger asks you for it.
Without Advanced, you can put show custom dialogs in places in your script, such as just after the go to layout step to see if the script actually took you to the layout you expected before a possible other script performed by a script trigger might take the user to a different layout.
Nearly every script trigger in FileMaker might be tripped by a layout change depending on the current focus on a given layout before the change takes place.
If you are using one of the "by calculation options" of go to layout, it may be that your calculation does not always evaluate to the actual name or number of a layout.
I tried debugging it. As soon as I entered the password, there were two scripts in the call stack, the first one was the OnFileMakerOpen and the second one was the script that is taking the users to the wrong layout. Now I am not sure why the second script came to the call stack. How do I track this?
Sounds like your first script is tripping a script trigger.
The name of the script trigger being tripped should appear in the top of the script debugger.
Use the script debugger in Fm Adv and step thru the scripts one step at a time
I am still not able to find the additional scripts that are getting executed in addition to the OnFilemakerOpen script when I open filemaker. I think this can be replicated when you open some other layout and close it and open the filemaker again. The file can be downloaded using the link
full access username: csd
When we login as the user, the layout "Student - Approved hours" will open
As I posted previously, the name of the responsible trigger is shown in the top of the debugger window when the script it performed is executing.
You have an OnFirstWindowOpen trigger that performs a script each time that the file is opened.
You also have an OnLayoutEnter Trigger on your "admin" layout. Since your file always opens to the admin layout, both triggers are tripped in the sequence of OnFirstWindowOpen, then OnLayoutEnter. So the first script takes you to the student layout only for the OnLayoutEnter triggered script to bring you back to the admin layout.
In File Options, specify some other layout as the initial layout and you should then avoid this issue.
Sorry, that did not work for me.
The second script that is being tripped is not always the OnLayoutEnter, the layout on OnLayoutEnter is not being opened.
Step1: I logged in as a Student and entered the "Student - Approved hours" layout
Step2: I closed the filemaker file.
Step3: I opened the same file and logged in using the adminstrator credentials, On the script debugger, I saw the OnFileMakerOpen and the On Enter layout of the layout that was opened in the last session.
I am not sure why that was opened.
PS: How do I use switch layout if I want different layouts opening for different user accounts.
You are specifying a layout from which to execute your script without tripping the extra trigger. This can be the same layout in all cases. It's just to make sure that the OnLayoutEnter trigger is not tripped AFTER the OnFirstWindowOpenTrigger.
Try the attached file. I used Manage | Layouts to look for a layout that does not have a script trigger and specified in in File Options. That's all it took to keep the OnLayoutEnter trigger from being tripped.
Import.fmp12.zip 1.6 MB