Properly register MBS FileMaker Plugin
Today we want to show you how to register our plugins properly in a solution.
This is the start script for your solution which calls the InitMBS script to register:
#Register for client
Perform Script [“InitMBS”]
#Register for server. Will be ignored if no server or no plugin installed on server
Perform Script on Server [“InitMBS”]
As you see we register both locally for the client and for the server. As we don't wait for server script to finish, it can run on server when there is time. And if there is no server, the line will be ignored. The InitMBS script looks like this:
#Enable debug logging. Shows messages in DebugView/Console.app
Set Variable [$r; Value:MBS("Trace")]
#Register if needed for right platform
If [MBS("IsRegistered") = 0]
If [MBS("IsRuntime")]
Set Variable [$r; Value:MBS("Register"; "test"; "Complete"; "Runtime"; 123; 123)]
Else If [MBS("IsServer")]
Set Variable [$r; Value:MBS("Register"; "test"; "Complete"; "Server"; 123; 123)]
Else If [MBS("IsClient")]
Set Variable [$r; Value:MBS("Register"; "test"; "Complete"; "5 Seats"; 123; 123)]
Else
Set Variable [$r; Value:"Unknown platform: " & MBS("Platform")]
End If
#Show errors, so developer can fix them
If [$r ≠ "OK"]
Show Custom Dialog ["InitMBS failed."; $r]
End If
End If
#May initialize other stuff
#like dynapdf with library in extensions folder
If [MBS("DynaPDF.IsInitialized") = 0]
Set Variable [$DynaPDFLicense; Value:"1003637-16022016-3-8-12-685C57F..."]
If [MBS("IsWindows")]
Set Variable [$r; Value:MBS( "DynaPDF.Initialize"; "dynapdf.dll"; $DynaPDFLicense)]
Else If [MBS("IsMacOSX")]
Set Variable [$r; Value:MBS( "DynaPDF.Initialize"; "dynapdf.dylib"; $DynaPDFLicense)]
Else
Set Variable [$r; Value:"Unknown platform: " & MBS("Platform")]
End If
#Show errors, so developer can fix them
If [$r ≠ "OK"]
Show Custom Dialog ["InitMBS failed."; $r]
End If
End If
As you see we enable Trace. This is useful to see calls to the plugin in DebugView application (Windows) and Console.app (Mac). For Server the messages are written to /Library/FileMaker Server/Logs/stderr.log file. On Windows you need to run DebugView as admin and enable Global Win32 Debug logging to see messages from Server plugin.
Next we check if plugins are not registered and register them with the right key depending on whether we are a client or server. If this fails, we show an error message. Next we check for DynaPDF and register it with a license key and the right name of the library. By just passing the library name, the plugin will look for this file in the same folder as the plugin itself.
If you have questions, please do not hesitate to contact us.