Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Getting Filemaker to call its own scripts externally

Featured Replies

Hope someone can help. I’m normally a mac guy so the specifically windows only areas of filemaker are new to me.

As you know, Filemaker is unable to call one of its own scripts by a calculated value. ‘Perform Script [xx]’ You always have to specify the existing script name and ‘hard code’ it into the trigger (button, other script or whatever).

What I’m wanting to do (as I’m sure many developers do) is to call a script based on a name stored in a record. I have a series of ‘resources’ or ‘tasks’ that appear in a menu (using a portal). I want to allow the user to click on a task and for filemaker to run a script based on that name stored in that record.

I have found a way of doing this on the mac using applescript. I store the following applescript template in a global...

[color:blue]tell application "FileMaker Pro Advanced"

do script "XXXX"

end tell

and then pass the ‘script name’ from the record to a substitute function to replace the ‘XXXX’ with the script name. Works beautifully.

Anyone know how to do an equivalent on Windows using combination of ‘Send DDE’ / VB Script / ActiveX etc. I know that you can call an FM script using ActiveX but how could I trigger this from Filemaker itself?

Cannot believe that Filemaker hasn’t produced a ‘Perform VBscript’ script step. In fact, cannot believe FM haven’t included a perform script name by calculation but there we are! I know this may be a little complicated but any help much appreciated - thanks guys.

Will

I guess that this by all means is the most ranted omission in the package at all. You might instead consider why it's omitted instead of me too'ing.

You have to consider that this tool have chosen a pretty unique approach by leaning up against the spreadsheet discourse.

We are provided with calc'fields autoenter values and field level validations, that with a bit of tinkering can be set to monitor other fields in the same record. This alone strains the list of usefull uses for event triggers considerably.

This difinitive distinction between functions and procedures is much harder than the approaches by other tools use. You might think that proper use of scripts is to generate records based on entries in fields - but it's NOT necessarily the truth - there exists a lot of situations where custom functions generates a returndelimited list that behaves as a join table in a many to many structure.

Next thing you might think of is the scripting required in order to make subsummary reports - again is it slightly prejudice to think that only scripting will deliver:

http://www.nightwing.com.au/FileMaker/demos8/demo803.html

...here is a combination of unstored calc'fields and CF's that makes it happen. But on the other hand is there of course limits to how large measures of data which can be processed this way.

When you scrutinize the mentioned template will you see that one single calc'function have made a hell of a change, to the over all scripting needed - namely GetNthRecord( if used properly in an autoenter or an unstored fields.

One thing that shouldn't be ignored is that the flatter a database structure is the more is scripting required!!!!

Therefore must your reply to this be a detailed description of the felt scripting need and a good description of your relational structure.

There is a fair chance that the habits learned elsewhere stands in the way of solving what really is the matter with your solution, filemaker is mistakenly assumed less steep a learningcurve than similar tools, but this leads unfortunately to badly founded solutions with only sporadic use of relation - without consideration of the two aspects relations serve 1) querries and 2) structure ...the first is way to often ignored.

--sd

I don't have a direct answer for you, but one possible workaround is to have the button in the portal pass the name as a script parameter to a master "traffic cop" script that is simply one long If/Else If ... Perform script. Not pretty, but workable for a few dozen scripts.

  • Author

Yes, you're right. I have used that method. In fact it's the only way really. A 'case' function works better but as you say, this method is not elegant. Thankyou anyway.

Will

You can also use the free plug-in EventScript to run scripts stored in variables. This plug-in can be installed under both Mac and Windows.

I looked into using it for a Reports module, where I wanted to be able to run an arbitrarily-defined list of reports without coding that humongous If/Then script... I didn't implement it ultimately because I wanted IWP compatibility, but if you're not constrained by that, you could try it out.

HTH,

David

  • Author

Thanks David, you're right I could use a plugin and I have used it before. However, the solution I'm working on is deployed to about 800 users and about 500 different computers. It's a big multi user school pupil tracking system. I should have mentioned this originally - sorry. A plugin would obviously work in theory but we'd have to install the plugin on every machine.

I'm able to accept two different methods for two different platforms but I wanted Filemaker and the OS to be able to handle this problem alone. Not wishing to be prejudiced against windows, I suspect that the relatively easy applescript method will not be easy to repeat on windows but I'm prepared to be proved wrong!

Apart from anything, any new skills I can learn on the windows side would be a good thing such as VB etc but not sure whether this is even possible. Thanks again for your input though.

Will

I think VBscript is your solution and I guess you will find useful informations about triggering a script from outside FileMaker (Windows) here :) http://www.connectingdata.com/downloads.htm

I didn't tried with a relative script name received from a FileMaker's field but this should work with your substitute trick and the Send Event script step.

Wim Decorte is the king for these advanced features. HTH.

  • Author

Wonderful! Thanks for that. That gives me a starting point at least. I'll check out that URL. I do see the name Wim Decorte all over the place - he does sound like an expert! Thanks.

Will

Thanks for the kind words, Gaston.

I've uploaded a "Run Script by Redirection" example to my website. It uses VBscript to call a specified script.

http://www.connectingdata.com/downloads.htm

let me know if you have any questions. There is one huge caveat: you can not pass a script parameter to a script from the outside. That's something FMI forgot to update in their ActiveX model when 7 came out... and again when 8 came out... and again when 8.5 came out. But we're patient.

Edited by Guest
typo

Apart from anything, any new skills I can learn on the windows side would be a good thing such as VB etc but not sure whether this is even possible.

I applaud you for willing to learn!

VB (Visual Basic) is the real programming language. Getting outdated now and getting replaced by VB.NET. VB/VB.NET produces compiled code (executables, DLLs,...).

VBscript is more like Applescript: it's built right into the OS and you need nothing more than Notepad to write your code in. Save it with the ".vbs" extension and away you go. Free and easy to learn.

Start here: www.microsoft.com/scripting

And feel free to ask any and all questions here.

  • Author

Thanks Wim. I'll certainly try it out. What about the triggering from Filemaker itself. Is there a way of doing this or does a vb script always have to sit outside filemaker and be launched as a separate entity. Nice thing about Applescript in FM is that you can call it right from within. Would I use 'Send DDE' or 'Send Event'? Many thanks for your feedback.

Will

  • Author

Sorry Wim - didn't see your second last post. Thanks for uploading that example. Guess you've answered my questions. Many thanks.

Will

Ummm, out of curiosity, what is the potential use of calling a script in filemaker, externally - outside of filemaker, if filemaker has to be open for the script to be called?

forget about DDE. It's dead technology.

When you're using Perform AppleScript on the Mac, it does not stay within FM. It does the same thing as the VBscript, it goes outside of FM and then talks back to it. The fact that you can trigger the AppleScript syntax from within FM may be misleading. FM just passes it on the OS and it is the OS that executes it.

Not quite sure what your point is Genx...

If you want to call a FM script dynamically from inside FM, of course FM would have to be running.

But if you just want to call a FM script completely outside of FM then there are ways in the ActiveX model to launch FM (hidden or visible), have it open a file, run a script and shut down again.

Care to share Wim? Pretty please?

I just want to open a file, run a script, close the file, all invisibily?

It's all in the help file, under "ActiveX"...

But just to make it easy (see screenshot).

Note:

- there is no error handling. What you really need to handle is checking if FM is already running (because this script will close it at the end)

- change the 4 lines below "configuration" to match your setup.

- save the file with a ".vbs" extension

vtc_20060723_00.jpg

Thanks a lot Wim, i really will have a look at the active X stuff now.

Cheers

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.