Trigger script in another solution

Hello!

I have built an amazing app (runs on a fmp server) we're I run 6 fmp files (4 host of databases) and 2 fmp file with the interface, scripts and logic.

My issue is that I need to add each user in all 6 fmp files manually, I want to make a script that creates all users at once on all fmp files. I tried using the fmp url but I can't get this this to work (with my current solution it cant be run in web, all has to be done inside fm and also work in webdirect)

Another way to solve this would be that auto login to external databases with same user for all users.

Anybody has any ideas or solution?

Here you can find a demo file for managing accounts over multiple FileMaker files:

Found that gem yesterday. Cool thing!

1 Like

If my memory serves me well, this only works for Filemaker accounts, not for external authentication like server accounts.

1 Like

I think you are right, @Torsten. But server group accounts one creates only once in a while. These to create manually in each file should not be too time wasting. And normally you have only a handfull of these.

1 Like

Without reading the blog from @mipiano, which I suspect will be similar, we create our own Human Resources/Account Management module, which allows us to setup user accounts with a group and temporary password (to change on first login) within a standard FileMaker record. The script then adds, removes, or changes password as desired in the UI file and calls scripts in each of the other files by passing the 3 essential credentials via JSON parameters and sets the accounts up.

This of course could loop through records that have been setup for multiple users and set all users up within a single routine.

2 Likes

Can you drop an example how you call a script from file A to file B with JSON.

This was a huge help, I set password for Admin user for all files and it's still works.

Can you drop an example how you call a script from file A to file B with JSON.

@jojolito , look at the script "Add User - Save" in the demo file that you could download from the linked article above. There are script calls with json parameters. You can specify a script from an other file (data source).

In this case the parameter looks like:

JSONSetElement ( "" ;  
	[ "accountName" ; $accountName ; JSONString ];
	[ "password" ; $password ; JSONString ];
	[ "privilege" ; $privilege ; JSONString ]
)

Hi @jojolito

@mipiano has provided the info, I'm not sure if you have all what you need, but just in case:

A script in one file can call a script in another by selecting the other file from the drop down that normally says "Current File (FileName)" and adds that file as a data source.

After that, you can exchange parameters exactly as you can between scripts in the same file. Hence, sending JSON as per @mipiano has suggested works fine when you use Get ( ScriptParameter ) in the called script.

All you need to do is ensure the additional files have the same privilege sets as the UI file and can then use If(), Else If() to match the privilege and then have the 'Add Account', 'Delete Account', 'Enable Account' and 'Reset Account Password' script steps in the appropriate scripts.

I suggest you set all the scripts to 'Grant Full Access Privileges' to ensure users with access to the layout that will trigger this can run the routine, regardless of how their account privileges have been setup.

Hope all of the above helps.

2 Likes

Works but not in webdirect, need to solve it to run on server.

Why shouldn't it? When I look into the script and choose to display which functions work in webdirect, none of the account managing functions is greyed out.

I'll try in the evening.

If you have use MBS FileMaker Plugin, you can use FM.RunScript function to run a script in another file.

Also you can use WebHook functions to define your own way to trigger URLs on the target computer, so you can query a script on another computer (or same).

1 Like

Hello @jojolito ,
now I found the time to test it with webdirect. It works fine. You just need to enable webdirect access in each file you want to manage the users with.

It has fatal errors (meaning you have to crash FileMaker) if you are trying to create an account which already exists in one of the files and the management of account deletion doesn't fair well if the account has been given full access privileges in some of the file: won't get deleted in those but the list of the accounts in the manage accounts layout will not reflect that.

@Cecile
This solution works - as it is - only if the users managed with it have the same privilege sets in all files. If you need exceptions, you have to consider this in the scripts. In addition, full access accounts should not be managed with this solution - if only for security reasons.