# Trigger script in another solution

**URL:** <https://the.fmsoup.org/t/trigger-script-in-another-solution/3032>\
**Category:** Questions\
**Tags:** script, filemaker-server, filemaker\
**Created:** [August 3, 2022, 10:24am UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032 "2022-08-03T10:24:53Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jojolito](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jojolito](https://the.fmsoup.org/u/jojolito)\
**Post date:** [August 3, 2022, 10:24am UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/1 "2022-08-03T10:24:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [August 3, 2022, 11:17am UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/2 "2022-08-03T11:17:06Z")

</div>

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

> **[Managing Accounts in a Multi-file Solution - AppWorks](https://app.works/managing-accounts-in-a-multi-file-solution/)**
>
> Do you have a FileMaker solution made of multiple files? This blog will show how to easily manage accounts for a multi-file solution.

Found that gem yesterday. Cool thing!

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [August 3, 2022, 12:24pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/3 "2022-08-03T12:24:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [August 3, 2022, 1:08pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/4 "2022-08-03T13:08:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AndyHibbs](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/andyhibbs/32/3089_2.png) [@AndyHibbs](https://the.fmsoup.org/u/AndyHibbs)\
**Post date:** [August 3, 2022, 8:07pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/5 "2022-08-03T20:07:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jojolito](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jojolito](https://the.fmsoup.org/u/jojolito)\
**Post date:** [August 4, 2022, 4:34pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/6 "2022-08-04T16:34:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jojolito](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jojolito](https://the.fmsoup.org/u/jojolito)\
**Post date:** [August 4, 2022, 4:35pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/7 "2022-08-04T16:35:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [August 4, 2022, 4:42pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/8 "2022-08-04T16:42:43Z")

</div>

> 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:

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

```

---

<div class="post-metadata">

**Author:** ![AndyHibbs](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/andyhibbs/32/3089_2.png) [@AndyHibbs](https://the.fmsoup.org/u/AndyHibbs)\
**Post date:** [August 4, 2022, 6:07pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/9 "2022-08-04T18:07:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jojolito](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jojolito](https://the.fmsoup.org/u/jojolito)\
**Post date:** [August 5, 2022, 1:08pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/10 "2022-08-05T13:08:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [August 5, 2022, 2:20pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/11 "2022-08-05T14:20:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [August 5, 2022, 2:34pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/12 "2022-08-05T14:34:29Z")

</div>

If you have use [MBS FileMaker Plugin](https://www.monkeybreadsoftware.com/filemaker/), you can use [FM.RunScript](https://www.mbsplugins.eu/FMRunScript.shtml) function to run a script in another file.

Also you can use [WebHook](https://www.mbsplugins.eu/component_WebHook.shtml) functions to define your own way to trigger URLs on the target computer, so you can query a script on another computer (or same).

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [August 7, 2022, 9:05am UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/13 "2022-08-07T09:05:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cecile](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/cecile/32/98_2.png) [@Cecile](https://the.fmsoup.org/u/Cecile)\
**Post date:** [January 2, 2023, 3:48am UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/14 "2023-01-02T03:48:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [January 2, 2023, 9:04pm UTC](https://the.fmsoup.org/t/trigger-script-in-another-solution/3032/15 "2023-01-02T21:04:12Z")

</div>

@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.
