FileMaker does not have a "Perform Script By Name" script step but I believe you could do this using "Open URL" and the fmp:// url protocol.
I suspect there may be a better way to handle this rather than adding a new script for every new "option". If you describe your solution and goals in more detail, we may be able to suggest a different approach.
I found another way to "sort of" do this... setup a layout that has multiple objects on it, each object has an on object enter script trigger - your calling script could just simply goto layout, goto object (name by calc) and when the object is entered, it would then run the script. Not elegant, but I find it comes in handy also when you want to run scripts separately - put them on this layout and you can click on them when you wish...
not elegant, I know, but it's more of a utility than anything else.
1 of 1 people found this helpful
As people have suggested, there are ways to dynamically call a script by name, but it's not really supported. The two purely dynamic ways to do it currently are using the fmp url scheme which isn't totally reliable and via the PHP web-publishing API, which is often not available (i.e. if you're not using FileMaker Server) and a fair bit of hassle to set up just for this purpose.
And since the advent of script triggers we've been able to do a few more things.
The other approach is the one you are already using. It's not fully dynamic as you have to add each script as you make it, but it's generally more reliable than the dynamic methods.
In any case, I tend to find that being able to call any script by name is much better in theory than in practice. FileMaker only really gives us one tool to handle the metadata of solutions: the Database Design Report (DDR). It's much harder to work with a DDR that uses one big handler script or dynamic script calling. In the case of dynamic script calling most currently available DDR analysis tools will not register calls to scripts made using the fmp url scheme so are unlikely to be able to report where each script is used. In the case of a large handler script you tend to end up with hundreds or thousands of calls to the handler script and no easy way to work out how many times to subsequent scripts are called.
Given that it's usually larger systems that "benefit" from handler scripts or calling scripts dynamically by name this can lead to serious code maintenance issues.
Thanks everyone for the options.
I kinda like the Object option from Peter.
I can have one master layout with objects that then trigger scripts.
Yes, I know, this sounds more complicate to maintain then my current scripting issue.
It will allow me to give maintenance to the InHouse IT persons without giving him access to edit scripts. I can give him layout access to ONE layout and teach him about Object and Script Triggers. This way he can change which scripts are available.
If you've got a solid use case then there's no reason not to try it out. As long as you understand the maintenance implications and document the technique then I would go for it.
Through the FileMaker Security you can control which Scripts a user can edit. Seems like a lot less work to allow them to edit just one script versus creating a new object and assigning whatever script they want to an OnEnter trigger. You also have to leave the current layout to go to another layout which might cause your script to lose focus.