Only thing I can think of is that you have an extra and invisible character in your layout name such as a leading or trailing space character.
Make sure that the layout name is really "customer" and not " customer" or "customer ".
Yes, that was the first thought when I encountered this issue. I am 100% sure there does not have any hidden characters before or after on my layout name and my list. I used debug and check the $layout variable carefully. It is "customer".
I'm suggesting that the layout name may have an extra character rather than the text stored in your $Layout variable.
As test, I'd perform this script on the customer layout and see what I get:
Show Custom Dialog [Quote ( Get ( LayoutName ) ) ]
You should see: "customer" in the custom dialog. If you see a space between the quotes and the name or a quotation mark starts on a new line, then you know that this is not the case.
If your are running the script debugger to check your script, then that would rule out another possibility, which is an OnLayoutEnter or OnRecordLoad script trigger on that layout that might perform after this script takes you to the layout and in doing so, take you to a different layout.
What actually happens when you use Go to Layout($$LayoutName) and $$layoutName is declared as "customer"? Does FileMaker return an error? Does it go to a different layout?
What happens when you use Go to Layout("customer") and hardcode the name rather than use a variable?
1. the layout name is "Customer" from Show Custom Dialog [Quote ( Get ( LayoutName ) ) ]
2. No error code and nothing happen. It stays at same layout.
3. Hardcode Go to layout("customer") is same. No error code and nothing happen.
I have 30+ layout and 9 of it cannot use Go to layout("layoutname") to show up layout.
As Phil says, check for script triggers on the customer layout and the layout you're leaving.
What happens when you try to navigate using the Layout menu? The Go to Layout menu item? A Go to Layout... script step (not "by name"?
If all else fails try recovering the file and test the recovered file (even if the recover process reports not finding any problems) to see if the problem persists in the recovered copy.
Things to keep in mind about Recover:
Recover does not detect all problems
Recover doesn't always fix all problems correctly
Best Practice is to never put a recovered copy back into regular use or development. Instead, replace the damaged file with an undamaged back up copy if this is at all possible. You may have to save a clone of the back up copy and import all data from your recovered copy to get a working copy with the most up to date information possible.
This is the cause: you have a layout folder with the name 'customer'. Change that and it works.
Thank you. It works, finally.