In this article we want to introduce you the new functions from the MBS FileMaker Plugin in version 12.1.
WebHook
We already introduced the new WebHook component in the release 11.5. In the new release we provide a few new functions that should make your work with WebHooks easier. With the function WebHook.SetMaximumRequestSize we set the maximum allowed request size. This allows you to disconnect sockets, which send too much data. By default there is no limit, so people can send requests with several gigabytes of payload. Depending on your use can it may be worth to limit request size to a reasonable value. For example if you receive notifications from your phone system, you may set the maximum size to 10000 bytes and a timeout of 60 seconds for WebHook.SetTimeOut function. That is probably 10 times more than needed, but may avoid some malicious user from sending a ton of useless traffic. Matching to this there is the WebHook.GetMaximumRequestSize function which queries this set value if needed. We can also get the size of a certain web request. WebRequest.GetSizereturns the total size of the request. The WebRequest.GetBodySize function then gives us the size of the body.
WebView
When you use custom web viewer with our plugin, you may run into the situation, that FileMaker rebuilds the layout (e.g. after changing a value list). But sometimes you want to prove if it was really rebuild or you must do it by your own. For that situation we got the function WebView.HasParent. It checks whether the WebView has a parent control. If this function return 0, you know the layout was rebuild and the custom web viewer is no longer visible. Otherway you can rebuild it. So when you have a script triggered by user going to new layout, you can check the status of web viewer and if needed rebuild it. Or change workflows, so if user needs to change a value list, they may need to open a card window then reach the edit dialog and when they click back button to close card, you can recreate the web viewer and load the content again.
Math
You want to calculate with FileMaker? Then I can recommend the new math functions. Calculate now the average, the maximum, minimum, the median, Sum, Standard Deviation and the Reciprocal with different numbers from a List. In the appropriate functions, you can specify a list of values that will be processed in the functions. Depending on the function, a single value or again a list is returned. With the function Math.Multiply we also have a function that can multiply the values of a list with a fixed value or with the entries of a second list. In the following example you can see the output of the functions for the always same list:
Audit
For the Audit area we have the new function Audit.Statistics. It queries statistics for Audit as JSON. You get the number of calls, fields and records, but also for the different error types like insert error or field type errors. If all things run normally the error counts are all zero. Additional we have the schema informations, how often we query the schema for tables, the schema for fields or related schema queries.
Files
With the new Files.AudioCoverArt function we can query the cover image of a file. You can retrieve the cover of MP3, MP4 and FLAC files. As return you will get an image as container value in JPEG, PNG, GIF or BMP format. The image format depends on which image is stored in the cover information. In the parameters of the function you can specify the file path where the file is located from which you want to retrieve the cover. Please note that the path must be a native path. If we have the file only as a FileMaker path, it can be easily converted with the Path.FileMakerPathToNativePath function.
Dictionary
We also have a new cool function in the Dictionary component. With the new Dictionary.Lookup function we query a value from the dictionary. If the key doesn't exist in the dictionary, we return the given default value instead of an error.
Plugin
The new function Plugin.GetFunctionParameters helps you if you need more information about the parameters of a plugin function. It gives you the metadata for the parameter list. In the function you can specify the function name and get a list of all parameter names.
Text
Sometimes you just have to look at things the other way around. The Text.Reverse function helps you to do this by writing a text from the bottom to the front, in other words, it completely reverses the order of the letters.
DynaPDF
There is also news from the Dyna PDF area. With the new function DynaPDF.SetSpaceWidthFactor you can now set the space width factor. The space width factor is used by DynaPDF.ExtractText to determine whether the distance between two text records or glyphs should be interpreted as space character. PDF files do often not contain space characters. Depending on the font type, i.e. fixed pitch or proportional fonts, different default widths are used during text extraction. However, the full space width is mostly too large to find spaces. Therefore, the text extraction algorithm multiplies the default space width with the space width factor to find suitable values.
Mac
There are also new features for Mac and the use of our plugin with the FileMaker iOS SDK:
Syntax help for your scripts
Already in the last release we introduced the autocompletion for variables in FileMaker. We have now extended the autocompletion to the function names of the MBS FileMaker Plugin. If you now want to write a MBS function in a formula dialog you will get the function names suggested. This selection list will be specified the more text you enter. Our function names always have a similar structure. First we write the component and then with a dot separated the actual name of the function. If you enter only the name of the component and a dot, you can see all the functions of a given component. If there are many, you can even scroll through the list. If you then confirm a name, the rest of the function is completed with placeholder parameter names, so that you can easily insert your own parameters without forgetting any.
We would now like to provide script colouring for texts as well. If you have a script text that you would like to colorize as the plugin displays it in the script area, the SyntaxColoring.ColorizeScript function can provide you with useful services. It will colorize your plain text.
Window
Two new cool functions are available for our Window functions. With the new function Window.SetCloseTrigger you can decide what should happen when a specific window or webviewer is closed. In the function you store on the one hand the reference of the window or webviewer and on the other hand information about the script that should be started when closing the referenced window. By the way, this script does not have to come from the same FM file in which the window was opened, but we can specify the file in the parameters. With the Window.ClearCloseTrigger function we can reset the script trigger and assign it to a new script if we want.