MBS FileMaker Plugin Example Databases

FileMaker Custom Functions

All examples are included with download of MBS FileMaker Plugin.

FileMaker Custom Functions.fmp12

Overview
Tables2
Relationships1
Layouts2
Scripts6
Value Lists0
Custom Functions0
Custom Menus24
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenScript: Start Script
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
CustomFunctions
7 fields defined, 7 records
CustomFunctions
CustomFunctionParameters
5 fields defined, 10 records
CustomFunctionParameters

Fields

Table Name: CustomFunctions - 7 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
IDNormal, NumberAuto-Enter:
  • Allow editing
  • Serial: Generate: On creation, Next value: 9, Increment: 1
Validation:
  • Only during data entry
  • Unique
Storage:
  • Repetitions: 1
  • Indexing: All
  • Index Language: German
        NameNormal, TextAuto-Enter:
        • Allow editing
        Validation:
        • Only during data entry
        Storage:
        • Repetitions: 1
        • Indexing: None
        • Automatically create indexes as needed
        • Index Language: German
            DeclarationNormal, TextAuto-Enter: Validation:
            • Only during data entry
            Storage:
            • Repetitions: 1
            • Indexing: None
            • Automatically create indexes as needed
            • Index Language: German
                  DescriptionNormal, TextAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                        BodyNormal, TextAuto-Enter:
                        • Allow editing
                        Validation:
                        • Only during data entry
                        Storage:
                        • Repetitions: 1
                        • Indexing: None
                        • Automatically create indexes as needed
                        • Index Language: German
                            ResultNormal, TextAuto-Enter:
                            • Allow editing
                            Validation:
                            • Only during data entry
                            Storage:
                            • Repetitions: 1
                            • Indexing: None
                            • Automatically create indexes as needed
                            • Index Language: German
                                SampleCallNormal, TextAuto-Enter: Validation:
                                • Only during data entry
                                Storage:
                                • Repetitions: 1
                                • Indexing: None
                                • Automatically create indexes as needed
                                • Index Language: German

                                      Table Name: CustomFunctionParameters - 5 Fields
                                      Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
                                      IDNormal, NumberAuto-Enter:
                                      • Allow editing
                                      • Serial: Generate: On creation, Next value: 11, Increment: 1
                                      Validation:
                                      • Only during data entry
                                      • Unique
                                      Storage:
                                      • Repetitions: 1
                                      • Indexing: All
                                      • Index Language: German
                                          NameNormal, TextAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                              DescriptionNormal, TextAuto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: German
                                                    FunctionIDNormal, NumberAuto-Enter:
                                                    • Allow editing
                                                    Validation:
                                                    • Only during data entry
                                                    Storage:
                                                    • Repetitions: 1
                                                    • Indexing: All
                                                    • Index Language: German
                                                        ValueNormal, TextAuto-Enter:
                                                        • Allow editing
                                                        Validation:
                                                        • Only during data entry
                                                        Storage:
                                                        • Repetitions: 1
                                                        • Indexing: None
                                                        • Automatically create indexes as needed
                                                        • Index Language: German

                                                            Layout Objects: CustomFunctions

                                                            Regular Fields

                                                            Field Name: CustomFunctions::Name
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 126 pt
                                                            • Left: 137 pt
                                                            • Bottom: 157 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Left and Right, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctions::Declaration
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 161 pt
                                                            • Left: 137 pt
                                                            • Bottom: 192 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Left and Right, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctions::Description
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 196 pt
                                                            • Left: 137 pt
                                                            • Bottom: 227 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Left and Right, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctions::Body
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 451 pt
                                                            • Left: 138 pt
                                                            • Bottom: 757 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Left and Right, Top and Bottom
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctionParameters::Name
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 250 pt
                                                            • Left: 145 pt
                                                            • Bottom: 281 pt
                                                            • Right: 394 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctionParameters::Description
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 250 pt
                                                            • Left: 398 pt
                                                            • Bottom: 281 pt
                                                            • Right: 706 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctionParameters::Value
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 250 pt
                                                            • Left: 711 pt
                                                            • Bottom: 281 pt
                                                            • Right: 960 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctions::SampleCall
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 849 pt
                                                            • Left: 138 pt
                                                            • Bottom: 880 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Left and Right, Bottom
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctions::Result
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 766 pt
                                                            • Left: 140 pt
                                                            • Bottom: 797 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Buttons

                                                            Button PropertiesCoordinatesScript/Script Step
                                                              Type:
                                                            • Text: Register and Try
                                                            • Top: 798 pt
                                                            • Left: 788 pt
                                                            • Bottom: 838 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Right, Bottom
                                                            Perform Script [ “Test Function” ]

                                                            Scripts:


                                                            Button PropertiesCoordinatesScript/Script Step
                                                              Type:
                                                            • Text: Register Function
                                                            • Top: 798 pt
                                                            • Left: 595 pt
                                                            • Bottom: 838 pt
                                                            • Right: 775 pt
                                                            • Anchoring: Left, Bottom
                                                            Perform Script [ “Register Function” ]

                                                            Scripts:


                                                            Button PropertiesCoordinatesScript/Script Step
                                                              Type:
                                                            • Text: Check
                                                            • Top: 798 pt
                                                            • Left: 415 pt
                                                            • Bottom: 838 pt
                                                            • Right: 595 pt
                                                            • Anchoring: Left, Bottom
                                                            Perform Script [ “CheckError” ]

                                                            Scripts:


                                                            Button PropertiesCoordinatesScript/Script Step
                                                              Type:
                                                            • Text: Format
                                                              Hide Condition:
                                                            • MBS( "IsMacOS" ) ≠ 1
                                                            • Top: 798 pt
                                                            • Left: 235 pt
                                                            • Bottom: 838 pt
                                                            • Right: 415 pt
                                                            • Anchoring: Left, Bottom
                                                            Perform Script [ “Format” ]

                                                            Scripts:


                                                            Portals

                                                            Portal PropertiesCoordinatesFieldsOptions
                                                            • Top: 245 pt
                                                            • Left: 140 pt
                                                            • Bottom: 442 pt
                                                            • Right: 968 pt
                                                            • Anchoring: Left, Top
                                                            Field Objects
                                                            • Sort records: Off
                                                            • Filter calculation: None
                                                            • Initial Row: 1
                                                            • Number of Rows: 5
                                                            • Allow deletion of portal records

                                                            Layout Objects: CustomFunctionParameters

                                                            Regular Fields

                                                            Field Name: CustomFunctionParameters::ID
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 114 pt
                                                            • Left: 138 pt
                                                            • Bottom: 145 pt
                                                            • Right: 217 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctionParameters::Name
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 155 pt
                                                            • Left: 138 pt
                                                            • Bottom: 186 pt
                                                            • Right: 391 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctionParameters::Description
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 190 pt
                                                            • Left: 138 pt
                                                            • Bottom: 221 pt
                                                            • Right: 391 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctionParameters::FunctionID
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 225 pt
                                                            • Left: 138 pt
                                                            • Bottom: 256 pt
                                                            • Right: 217 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Field Name: CustomFunctionParameters::Value
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 260 pt
                                                            • Left: 138 pt
                                                            • Bottom: 291 pt
                                                            • Right: 391 pt
                                                            • Anchoring: Left, Top
                                                            Field Format:
                                                            • Edit Box
                                                            Field Behavior:
                                                            • Allow field to be entered: In Find mode, In Browse mode
                                                            • Touch keyboard type: Default for Data Type
                                                            • Go to next field using: Tab key
                                                            Yes

                                                            Script Hierarchy

                                                            Start Script
                                                            RefreshDeclaration
                                                            Register Function
                                                            Test Function
                                                            Format
                                                            CheckError

                                                            Next Script: [RefreshDeclaration]
                                                            Script NameStart Script
                                                            Run script with full access privilegesOff
                                                            Include In MenuYes
                                                            Layouts that use this script
                                                              Scripts that use this script
                                                                Script Definition
                                                                Script Steps
                                                                • If [ FilterValues ( MBS( "Dictionary.List" ); "CF" ) ≠ "CF¶" ]
                                                                • #Start script to create dictionary named CF. You can choose your name!
                                                                • Set Variable [ $CF; Value:MBS("Dictionary.CreateNamed"; "CF" ) ]
                                                                • If [ MBS("IsError") ]
                                                                • Show Custom Dialog [ Title: "Failed to initialize dictionary."; Message: $CF; Default Button: “OK”, Commit: “Yes” ]
                                                                • Set Variable [ $CF; Value:"" ]
                                                                • Exit Script [ ]
                                                                • End If
                                                                • #register all functions
                                                                • Go to Layout [ “CustomFunctions” (CustomFunctions) ]
                                                                • #you could do a search here to only find the functions you need
                                                                • Go to Record/Request/Page [ First ]
                                                                • Loop
                                                                • Perform Script [ “Register Function” ]
                                                                • Go to Record/Request/Page [ Next; Exit after last ]
                                                                • End Loop
                                                                • Go to Record/Request/Page [ First ]
                                                                • End If
                                                                • #clear result fields
                                                                • Replace Field Contents [ CustomFunctions::Result; Replace with calculation: "" ] [ No dialog ]
                                                                Fields used in this script
                                                                Scripts used in this script
                                                                Layouts used in this script
                                                                Tables used in this script
                                                                Table occurrences used by this script
                                                                Custom Functions used by this script
                                                                  Custom menu set used by this script

                                                                    Previous Script: [Start Script]Next Script: [Register Function]
                                                                    Script NameRefreshDeclaration
                                                                    Run script with full access privilegesOff
                                                                    Include In MenuYes
                                                                    Layouts that use this script
                                                                      Scripts that use this script
                                                                        Script Definition
                                                                        Script Steps
                                                                        • #assign value to itself to trigger calculation for declaration field
                                                                        • Set Field [ CustomFunctions::Name; CustomFunctions::Name ]
                                                                        Fields used in this script
                                                                        Scripts used in this script
                                                                          Layouts used in this script
                                                                            Tables used in this script
                                                                            Table occurrences used by this script
                                                                            Custom Functions used by this script
                                                                              Custom menu set used by this script

                                                                                Previous Script: [RefreshDeclaration]Next Script: [Test Function]
                                                                                Script NameRegister Function
                                                                                Run script with full access privilegesOff
                                                                                Include In MenuYes
                                                                                Layouts that use this script
                                                                                Scripts that use this script
                                                                                Script Definition
                                                                                Script Steps
                                                                                • #Register one function. Replacing older one with same name
                                                                                • Set Variable [ $r; Value:MBS( "Dictionary.SetValueForkey"; "CF"; CustomFunctions::Name; "/// " & Substitute(List ( CustomFunctionParameters::Name ); ¶; "¶/// ") & ¶ & ¶ & CustomFunctions::Body) ]
                                                                                • If [ MBS("IsError") ]
                                                                                • Show Custom Dialog [ Title: "Failed to add function."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                • End If
                                                                                Fields used in this script
                                                                                Scripts used in this script
                                                                                  Layouts used in this script
                                                                                    Tables used in this script
                                                                                    Table occurrences used by this script
                                                                                    Custom Functions used by this script
                                                                                      Custom menu set used by this script

                                                                                        Previous Script: [Register Function]Next Script: [Format]
                                                                                        Script NameTest Function
                                                                                        Run script with full access privilegesOff
                                                                                        Include In MenuYes
                                                                                        Layouts that use this script
                                                                                        Scripts that use this script
                                                                                          Script Definition
                                                                                          Script Steps
                                                                                          • #Register function
                                                                                          • Set Variable [ $r; Value:MBS( "Dictionary.SetValueForkey"; "CF"; CustomFunctions::Name; "/// " & Substitute(List ( CustomFunctionParameters::Name ); ¶; "¶/// ") & ¶ & ¶ & CustomFunctions::Body) ]
                                                                                          • If [ MBS("IsError") ]
                                                                                          • Show Custom Dialog [ Title: "Failed to add function."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                          • Else
                                                                                          • Set Variable [ $ParameterCount; Value:ValueCount ( List ( CustomFunctionParameters::ID ) ) ]
                                                                                          • Set Variable [ $r; Value:MBS( "FM.CF"; "CF"; CustomFunctions::Name; If($ParameterCount ≥ 1; GetNthRecord ( CustomFunctionParameters::Value ; 1)); If($ParameterCount ≥ 2; GetNthRecord ( CustomFunctionParameters::Value ; 2)); If($ParameterCount ≥ 3; GetNthRecord ( CustomFunctionParameters::Value ; 3)); If($ParameterCount ≥ 4; GetNthRecord ( CustomFunctionParameters::Value ; 4)); If($ParameterCount ≥ 5; GetNthRecord ( CustomFunctionParameters::Value ; 5)); If($ParameterCount ≥ 6; GetNthRecord ( CustomFunctionParameters::Value ; 6)); If($ParameterCount ≥ 7; GetNthRecord ( CustomFunctionParameters::Value ; 7)); If($ParameterCount ≥ 8; GetNthRecord ( CustomFunctionParameters::Value ; 8)); If($ParameterCount ≥ 9; GetNthRecord ( CustomFunctionParameters::Value ; 9)) ) ]
                                                                                          • Set Field [ CustomFunctions::Result; $r ]
                                                                                          • If [ MBS("ISError") ]
                                                                                          • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                          • End If
                                                                                          • End If
                                                                                          Fields used in this script
                                                                                          Scripts used in this script
                                                                                            Layouts used in this script
                                                                                              Tables used in this script
                                                                                              Table occurrences used by this script
                                                                                              Custom Functions used by this script
                                                                                                Custom menu set used by this script

                                                                                                  Previous Script: [Test Function]Next Script: [CheckError]
                                                                                                  Script NameFormat
                                                                                                  Run script with full access privilegesOff
                                                                                                  Include In MenuYes
                                                                                                  Layouts that use this script
                                                                                                  Scripts that use this script
                                                                                                    Script Definition
                                                                                                    Script Steps
                                                                                                    • If [ MBS( "IsMacOS" ) = 1 ]
                                                                                                    • Set Variable [ $r; Value:TextSize ( MBS( "SyntaxColoring.Format"; CustomFunctions::Body; 0 ); 16) ]
                                                                                                    • Set Field [ CustomFunctions::Body; $r ]
                                                                                                    • End If
                                                                                                    Fields used in this script
                                                                                                    Scripts used in this script
                                                                                                      Layouts used in this script
                                                                                                        Tables used in this script
                                                                                                        Table occurrences used by this script
                                                                                                        Custom Functions used by this script
                                                                                                          Custom menu set used by this script

                                                                                                            Previous Script: [Format]
                                                                                                            Script NameCheckError
                                                                                                            Run script with full access privilegesOff
                                                                                                            Include In MenuYes
                                                                                                            Layouts that use this script
                                                                                                            Scripts that use this script
                                                                                                              Script Definition
                                                                                                              Script Steps
                                                                                                              • Set Error Capture [ On ]
                                                                                                              • Set Variable [ $liste; Value:List ( CustomFunctionParameters::Name ) ]
                                                                                                              • If [ ValueCount ( $liste ) = 0 ]
                                                                                                              • Set Variable [ $body; Value:CustomFunctions::Body ]
                                                                                                              • Else
                                                                                                              • Set Variable [ $body; Value:"Let([" & ¶ & Substitute($liste; ¶; " = 0;¶") & " = 0;" & ¶ & ¶ & "r = " & ¶ & CustomFunctions::Body & ¶ & "]; r)" ]
                                                                                                              • End If
                                                                                                              • Set Variable [ $expression; Value:"If(false; Let(r=" & $body & "¶;0))" ]
                                                                                                              • Set Variable [ $e; Value:EvaluationError(Evaluate($expression)) ]
                                                                                                              • Set Field [ CustomFunctions::Result; If($e = 0; "No Error"; "Error " & $e & ": " & MBS("FM.ErrorMessage"; $e)) ]
                                                                                                              Fields used in this script
                                                                                                              Scripts used in this script
                                                                                                                Layouts used in this script
                                                                                                                  Tables used in this script
                                                                                                                  Table occurrences used by this script
                                                                                                                  Custom Functions used by this script
                                                                                                                    Custom menu set used by this script

                                                                                                                      Download example: FileMaker Custom Functions

                                                                                                                      Used functions:




                                                                                                                      Links
                                                                                                                      MBS FileMaker tutorial videos

                                                                                                                      Start Chat