Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

FileMaker Custom Functions via Dictionary

All examples are included with download of MBS FileMaker Plugin.

FileMaker Custom Functions via Dictionary.fmp12

Overview
Tables 2
Relationships 1
Layouts 2
Scripts 6
Value Lists 0
Custom Functions 0
Custom Menus 24
File Options
Default custom menu set [Standard FileMaker Menus]
Default theme Apex Blau
When opening file
Minimum allowed version 12.0
Login using Account Name; Account= Admin
Allow user to save password On
Require iOS passcode Off
Show Sign-in fields Off
Switch to layout Off
Hide all toolbars Off
Script triggers
OnFirstWindowOpen Script: Start Script
OnLastWindowClose Off
OnWindowOpen Off
OnWindowClose Off
OnFileAVPlayerChange Off
OnWindowTransaction Off
Thumbnail Settings
Generate Thumbnails On; Temporary

 

Tables

Table Name
Statistics
Comments
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 Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
ID Normal, Number Auto-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
        Name Normal, Text Auto-Enter:
        • Allow editing
        Validation:
        • Only during data entry
        Storage:
        • Repetitions: 1
        • Indexing: None
        • Automatically create indexes as needed
        • Index Language: German
            Declaration Normal, Text Auto-Enter: Validation:
            • Only during data entry
            Storage:
            • Repetitions: 1
            • Indexing: None
            • Automatically create indexes as needed
            • Index Language: German
                  Description Normal, Text Auto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                        Body Normal, Text Auto-Enter:
                        • Allow editing
                        Validation:
                        • Only during data entry
                        Storage:
                        • Repetitions: 1
                        • Indexing: None
                        • Automatically create indexes as needed
                        • Index Language: German
                            Result Normal, Text Auto-Enter:
                            • Allow editing
                            Validation:
                            • Only during data entry
                            Storage:
                            • Repetitions: 1
                            • Indexing: None
                            • Automatically create indexes as needed
                            • Index Language: German
                                SampleCall Normal, Text Auto-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 Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
                                      ID Normal, Number Auto-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
                                          Name Normal, Text Auto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                              Description Normal, Text Auto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: German
                                                    FunctionID Normal, Number Auto-Enter:
                                                    • Allow editing
                                                    Validation:
                                                    • Only during data entry
                                                    Storage:
                                                    • Repetitions: 1
                                                    • Indexing: All
                                                    • Index Language: German
                                                        Value Normal, Text Auto-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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Script/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 Properties Coordinates Script/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 Properties Coordinates Script/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 Properties Coordinates Script/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 Properties Coordinates Fields Options
                                                            • 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Properties Coordinates Field Format Field Behavior Quick 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 Name Start Script
                                                            Run script with full access privileges Off
                                                            Siri Shortcut Visible Off
                                                            Include In Menu Yes
                                                            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 [ Flush: Always ]
                                                                • 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 Name RefreshDeclaration
                                                                    Run script with full access privileges Off
                                                                    Siri Shortcut Visible Off
                                                                    Include In Menu Yes
                                                                    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 Name Register Function
                                                                                Run script with full access privileges Off
                                                                                Siri Shortcut Visible Off
                                                                                Include In Menu Yes
                                                                                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 Name Test Function
                                                                                        Run script with full access privileges Off
                                                                                        Siri Shortcut Visible Off
                                                                                        Include In Menu Yes
                                                                                        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 Name Format
                                                                                                  Run script with full access privileges Off
                                                                                                  Siri Shortcut Visible Off
                                                                                                  Include In Menu Yes
                                                                                                  Layouts that use this script
                                                                                                  Scripts that use this script
                                                                                                    Script Definition
                                                                                                    Script Steps
                                                                                                    • Set Variable [ $r; Value:MBS("SyntaxColoring.FormatCalculation"; CustomFunctions::Body) ]
                                                                                                    • If [ MBS("IsError") ]
                                                                                                    • Show Custom Dialog [ Title: "Failed to format"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                    • Else [ ]
                                                                                                    • #add colors
                                                                                                    • Set Variable [ $f; Value:MBS("SyntaxColoring.Format"; $r) ]
                                                                                                    • If [ MBS("IsError") ]
                                                                                                    • Set Field [ CustomFunctions::Body; $r ]
                                                                                                    • Else [ ]
                                                                                                    • Set Field [ CustomFunctions::Body; TextSize ( $f ; 16 ) ]
                                                                                                    • 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: [Format]
                                                                                                            Script Name CheckError
                                                                                                            Run script with full access privileges Off
                                                                                                            Siri Shortcut Visible Off
                                                                                                            Include In Menu Yes
                                                                                                            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 via Dictionary

                                                                                                                      Used functions: