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

MBS FileMaker Plugin Example Databases

CURL and OnWindowTransaction

All examples are included with download of MBS FileMaker Plugin.

CURL and OnWindowTransaction.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts3
Value Lists0
Custom Functions1
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
OnFirstWindowOpenOff
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Table
12 fields defined, 1 record
Table

Fields

Table Name: Table - 12 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
PrimaryKeyNormal, TextAuto-Enter:
  • Context table: Table
    Calculation: Get( UUID )
Validation:
  • Only during data entry
  • Not empty
  • Unique
  • Strict validation
Storage:
  • Repetitions: 1
  • Indexing: Minimal
  • Automatically create indexes as needed
  • Index Language: Unicode Raw
Unique identifier of each record in this table
          CreationTimestampNormal, TimestampAuto-Enter:
          • Creation timestamp
          Validation:
          • Only during data entry
          • Strict data type: 4 digit year
          • Not empty
          • Strict validation
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
          Date and time each record was created
                  CreatedByNormal, TextAuto-Enter:
                  • Context table: Table
                    Calculation: Get(AccountName) & ": " & Get(UserName)
                  Validation:
                  • Only during data entry
                  • Not empty
                  • Strict validation
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                  Account name of the user who created each record
                          ModificationTimestampNormal, TimestampAuto-Enter:
                          • Modification timestamp
                          Validation:
                          • Only during data entry
                          • Strict data type: 4 digit year
                          • Not empty
                          • Strict validation
                          Storage:
                          • Repetitions: 1
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: German
                          Date and time each record was last modified
                                  ModifiedByNormal, TextAuto-Enter:
                                  • Context table: Table
                                    Calculation: Get(AccountName) & ": " & Get(UserName)
                                  Validation:
                                  • Only during data entry
                                  • Not empty
                                  • Strict validation
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: German
                                  Account name of the user who last modified each record
                                          TestNormal, TextAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                                NumberFieldNormal, NumberAuto-Enter:
                                                • Allow editing
                                                Validation:
                                                • Only during data entry
                                                Storage:
                                                • Repetitions: 1
                                                • Indexing: None
                                                • Automatically create indexes as needed
                                                • Index Language: German
                                                      DateFieldNormal, DateAuto-Enter:
                                                      • Allow editing
                                                      Validation:
                                                      • Only during data entry
                                                      Storage:
                                                      • Repetitions: 1
                                                      • Indexing: None
                                                      • Automatically create indexes as needed
                                                      • Index Language: German
                                                            TextFieldNormal, TextAuto-Enter:
                                                            • Allow editing
                                                            Validation:
                                                            • Only during data entry
                                                            Storage:
                                                            • Repetitions: 1
                                                            • Indexing: None
                                                            • Automatically create indexes as needed
                                                            • Index Language: German
                                                                  ContainerFieldNormal, BinaryAuto-Enter:
                                                                  • Allow editing
                                                                  Validation:
                                                                  • Only during data entry
                                                                  Storage:
                                                                  • Repetitions: 1
                                                                        Last Debug LogNormal, TextAuto-Enter:
                                                                        • Allow editing
                                                                        Validation:
                                                                        • Only during data entry
                                                                        Storage:
                                                                        • Global
                                                                        • Repetitions: 1
                                                                        • Index Language: German
                                                                            AuditJSONNormal, TextAuto-Enter: Validation:
                                                                            • Only during data entry
                                                                            Storage:
                                                                            • Repetitions: 1
                                                                            • Indexing: None
                                                                            • Automatically create indexes as needed
                                                                            • Index Language: German

                                                                                  Layout Objects: Table

                                                                                  Regular Fields

                                                                                  Field Name: Table::Test
                                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                  • Top: 114 pt
                                                                                  • Left: 138 pt
                                                                                  • Bottom: 145 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: Table::NumberField
                                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                  • Top: 149 pt
                                                                                  • Left: 138 pt
                                                                                  • Bottom: 180 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: Table::DateField
                                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                  • Top: 184 pt
                                                                                  • Left: 138 pt
                                                                                  • Bottom: 215 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: Table::TextField
                                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                  • Top: 219 pt
                                                                                  • Left: 138 pt
                                                                                  • Bottom: 344 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: Table::ContainerField
                                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                  • Top: 348 pt
                                                                                  • Left: 138 pt
                                                                                  • Bottom: 473 pt
                                                                                  • Right: 520 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
                                                                                  No

                                                                                  Field Name: Table::Last Debug Log
                                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                  • Top: 114 pt
                                                                                  • Left: 575 pt
                                                                                  • Bottom: 742 pt
                                                                                  • Right: 1013 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
                                                                                  No

                                                                                  Field Name: Table::AuditJSON
                                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                  • Top: 746 pt
                                                                                  • Left: 138 pt
                                                                                  • Bottom: 777 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

                                                                                  OnWindowTransaction
                                                                                  Transfer Finished
                                                                                  Clear

                                                                                  Next Script: [Transfer Finished]
                                                                                  Script NameOnWindowTransaction
                                                                                  Run script with full access privilegesOff
                                                                                  Siri Shortcut VisibleOff
                                                                                  Include In MenuYes
                                                                                  Layouts that use this script
                                                                                    Scripts that use this script
                                                                                      Script Definition
                                                                                      Script Steps
                                                                                      • #parameter is the JSON from FileMaker about the change
                                                                                      • Set Variable [ $json; Value:Get(ScriptParameter) ]
                                                                                      • Set Variable [ $URL; Value:"https://monkeybreadsoftware.com/filemaker/examples/email.php" ]
                                                                                      • #start a new curl session
                                                                                      • Set Variable [ $curl; Value:MBS("CURL.New") ]
                                                                                      • #configure transfer
                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionURL"; $curl; $URL) ]
                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionPostFields"; $curl; $json) ]
                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionHTTPHeader"; $curl; "Content-Type: application/json") ]
                                                                                      • #Let the evaluate then free the transfer
                                                                                      • // Set Variable [ $r; Value:MBS("CURL.SetFinishedEvaluate"; $curl; "MBS(\"CURL.Release\"; $$ID$$)" ) ]
                                                                                      • #or run a script to handle result
                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetFinishedScript"; $curl; Get(FileName); "Transfer Finished" ) ]
                                                                                      • #run in background thread asynchronously
                                                                                      • Set Variable [ $r; Value:MBS("CURL.PerformInBackground"; $curl) ]
                                                                                      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: [OnWindowTransaction]Next Script: [Clear]
                                                                                                    Script NameTransfer Finished
                                                                                                    Run script with full access privilegesOff
                                                                                                    Siri Shortcut VisibleOff
                                                                                                    Include In MenuYes
                                                                                                    Layouts that use this script
                                                                                                      Scripts that use this script
                                                                                                        Script Definition
                                                                                                        Script Steps
                                                                                                        • Set Variable [ $curl; Value:Get(ScriptParameter) ]
                                                                                                        • #check result?
                                                                                                        • Set Variable [ $Error; Value:MBS( "CURL.ErrorCode"; $curl ) ]
                                                                                                        • Set Variable [ $ResponseCode; Value:MBS( "CURL.GetResponseCode"; $curl ) ]
                                                                                                        • Set Variable [ $EffectiveURL; Value:MBS( "CURL.GetEffectiveURL"; $curl ) ]
                                                                                                        • Set Variable [ $DebugMessages; Value:MBS( "CURL.GetDebugMessages"; $curl ) ]
                                                                                                        • #let's put the log in the field. Using a card window to avoid changing context
                                                                                                        • Freeze Window
                                                                                                        • New Window [ Style: Card; Name: "Audit"; Using layout: “Table”; Close: Yes; Minimize: No; Maximize: No; Resize: No; Menu Bar: No; Dim parent window: No; Toolbars: No ]
                                                                                                        • Set Field [ Table::Last Debug Log; $DebugMessages ]
                                                                                                        • Close Window [ Name: "Audit"; Current file ]
                                                                                                        • Set Variable [ $r; Value:MBS("Curl.Release"; $curl) ]
                                                                                                        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: [Transfer Finished]
                                                                                                              Script NameClear
                                                                                                              Run script with full access privilegesOff
                                                                                                              Siri Shortcut VisibleOff
                                                                                                              Include In MenuYes
                                                                                                              Layouts that use this script
                                                                                                                Scripts that use this script
                                                                                                                  Script Definition
                                                                                                                  Script Steps
                                                                                                                  • Replace Field Contents [ Table::Last Debug Log; 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

                                                                                                                          Custom Functions

                                                                                                                          Function NameParametersAvailabilityDefinitionIn Field DefinitionsIn Scripts
                                                                                                                          GatherJSONFieldsAll accounts// GatherJSONFields ( ) = // Using various functions gather field // names, field values, layout // context, layout database // context, user context, and // current timestamp, then present // the data as JSON Let ( [ quoteReplace = "_0-~@~-0_" ; quote = "\\\"" ; newlineReplace = "_1-~@~-1_" ; newline = "\n" ; lytName = Get ( LayoutName ) ; tblName = Get ( LayoutTableName ) ; user = Get ( UserName ) ; ts = GetAsText ( Get ( CurrentHostTimestamp ) ) ; primaryKeyValue = Evaluate ( tblName & "::PrimaryKey" ) ; tblFields = ExecuteSQL ( "SELECT '''" & quoteReplace & "' + FieldName + '" & quoteReplace & " : " & quoteReplace & "'' + STRVAL(\"' + FieldName + '\") + ''" & quoteReplace & "''' FROM FileMaker_Fields WHERE TableName LIKE '" & tblName & "' AND FieldClass LIKE 'Normal' " ; "" ; ", " ) ; tblValues = ExecuteSQL ( "SELECT " & tblFields & " FROM " &" \"" & tblName & "\" WHERE PrimaryKey = '" & primaryKeyValue & "' " ; newlineReplace ; "" ) ; formattedLayoutName = "\"" & lytName & "\"" ; formattedTableName = "\"" & tblName & "\"" ; formattedValues = Substitute ( tblValues ; "\\" ; "\\\\" ) ; formattedValues = Substitute ( formattedValues ; "\"" ; quote ) ; formattedValues = Substitute ( formattedValues ; quoteReplace ; "\"" ) ; formattedValues = Substitute ( formattedValues ; "¶" ; newline ) ; formattedValues = Substitute ( formattedValues ; newlineReplace ; ", " ) ; formattedValues = "{ " & formattedValues & " }" ; formattedUser = Substitute ( user ; "\\" ; "\\\\" ) ; formattedUser = Substitute ( formattedUser ; "\"" ; quote ) ; formattedUser = Substitute ( formattedUser ; "¶" ; newline ) ; formattedUser = "\"" & formattedUser & "\"" ; formattedTimestamp = Substitute ( ts ; "\\" ; "\\\\" ) ; formattedTimestamp = Substitute ( formattedTimestamp ; "\"" ; quote ) ; formattedTimestamp = Substitute ( formattedTimestamp ; "¶" ; newline ) ; formattedTimestamp = "\"" & formattedTimestamp & "\"" ; JSONData = "{ " & "\"LayoutName\" : " & formattedLayoutName & ", " & "\"TableName\" : " & formattedTableName & ", " & "\"AccessingUser\" : " & formattedUser & ", " & "\"Timestamp\" : " & formattedTimestamp & ", " & "\"Fields\" : " & formattedValues & " }" ] ; JSONFormatElements ( JSONData ) )

                                                                                                                          Custom Menu Sets

                                                                                                                          Menu SetsMenusIn ScriptsIn LayoutsComments
                                                                                                                          [Standard FileMaker Menus]
                                                                                                                          • All Standard Menus

                                                                                                                          Download example: CURL and OnWindowTransaction

                                                                                                                          Used functions: