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

MBS FileMaker Plugin Example Databases

WebHook to serve html

All examples are included with download of MBS FileMaker Plugin.

WebHook to serve html.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts4
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
OnFirstWindowOpenOff
OnLastWindowCloseScript: Cleanup
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

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

Fields

Table Name: WebHook - 5 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
Server PortNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Global
  • Repetitions: 1
  • Index Language: German
        Server WebhookNormal, NumberAuto-Enter:
        • Allow editing
        Validation:
        • Only during data entry
        Storage:
        • Global
        • Repetitions: 1
        • Index Language: German
              Text1Normal, TextAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German
                  Text2Normal, TextAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                      TemplateNormal, TextAuto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Repetitions: 1
                      • Indexing: None
                      • Automatically create indexes as needed
                      • Index Language: German

                          Layout Objects: WebHook

                          Regular Fields

                          Field Name: WebHook::Text1
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 114 pt
                          • Left: 138 pt
                          • Bottom: 145 pt
                          • Right: 709 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: WebHook::Text2
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 149 pt
                          • Left: 138 pt
                          • Bottom: 180 pt
                          • Right: 709 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: WebHook::Template
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 184 pt
                          • Left: 138 pt
                          • Bottom: 561 pt
                          • Right: 709 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

                          Buttons

                          Button PropertiesCoordinatesScript/Script Step
                            Type:
                          • Text: Start
                          • Top: 39 pt
                          • Left: 25 pt
                          • Bottom: 70 pt
                          • Right: 178 pt
                          • Anchoring: Left, Top
                          Perform Script [ “Setup” ]

                          Scripts:


                          Button PropertiesCoordinatesScript/Script Step
                            Type:
                          • Text: Stop
                          • Top: 38 pt
                          • Left: 198 pt
                          • Bottom: 69 pt
                          • Right: 351 pt
                          • Anchoring: Left, Top
                          Perform Script [ “Cleanup” ]

                          Scripts:


                          Button PropertiesCoordinatesScript/Script Step
                            Type:
                          • Text: Open Browser
                          • Top: 38 pt
                          • Left: 371 pt
                          • Bottom: 69 pt
                          • Right: 524 pt
                          • Anchoring: Left, Top
                          Open URL [ "http://localhost:9999/" ] [ No dialog ]

                          Script Hierarchy

                          Setup
                          Cleanup
                          WebHookReceived
                          Change Answer

                          Next Script: [Cleanup]
                          Script NameSetup
                          Run script with full access privilegesOff
                          Include In MenuYes
                          Layouts that use this script
                          Scripts that use this script
                            Script Definition
                            Script Steps
                            • If [ Length( $$WebHooks ) > 0 ]
                            • Set Variable [ $r; Value:MBS("WebHook.Release"; $$WebHooks) ]
                            • Set Variable [ $$WebHooks; Value:"" ]
                            • Set Field [ WebHook::Server Webhook; "" ]
                            • End If
                            • If [ IsEmpty ( $$WebHooks ) ]
                            • Set Variable [ $$WebHooks; Value:MBS("WebHook.Create") ]
                            • Set Variable [ $r; Value:MBS("WebHook.SetAutoAnswer"; $$Webhooks; ""; "UTF-8") ]
                            • Set Variable [ $r; Value:MBS("WebHook.SetMode"; $$WebHooks; 1) ]
                            • Set Variable [ $r; Value:MBS("WebHook.Listen"; $$WebHooks; WebHook::Server Port) ]
                            • Set Variable [ $r; Value:MBS("WebHook.SetScript"; $$WebHooks; Get(FileName); "WebHookReceived") ]
                            • Set Field [ WebHook::Server Webhook; $$WebHooks ]
                            • 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: [Setup]Next Script: [WebHookReceived]
                                    Script NameCleanup
                                    Run script with full access privilegesOff
                                    Include In MenuYes
                                    Layouts that use this script
                                    Scripts that use this script
                                      Script Definition
                                      Script Steps
                                      • If [ not IsEmpty ( $$WebHooks ) ]
                                      • Set Variable [ $r; Value:MBS("WebHook.Release"; $$WebHooks) ]
                                      • Set Variable [ $$WebHooks; Value:"" ]
                                      • Set Field [ WebHook::Server Webhook; "" ]
                                      • 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: [Cleanup]Next Script: [Change Answer]
                                              Script NameWebHookReceived
                                              Run script with full access privilegesOff
                                              Include In MenuNo
                                              Layouts that use this script
                                                Scripts that use this script
                                                  Script Definition
                                                  Script Steps
                                                  • Set Variable [ $WebRequest; Value:Get(ScriptParameter) ]
                                                  • If [ MBS("WebRequest.GetHTTPMethod"; $WebRequest) = "GET" ]
                                                  • Set Variable [ $json; Value:MBS( "WebRequest.URLComponents"; $WebRequest ) ]
                                                  • #check path
                                                  • Set Variable [ $path; Value:JSONGetElement ( $json ; "Path" ) ]
                                                  • If [ $path = "/" ]
                                                  • Set Variable [ $Result; Value:WebHook::Template ]
                                                  • Set Variable [ $Result; Value:Substitute ( $Result; "$text1$" ; MBS("Text.EncodeToHTML"; WebHook::Text1) ) ]
                                                  • Set Variable [ $Result; Value:Substitute ( $Result; "$text2$" ; MBS("Text.EncodeToHTML"; WebHook::Text2) ) ]
                                                  • #send HTTP Response here
                                                  • #get length of answer
                                                  • Set Variable [ $body; Value:MBS( "Text.EncodeToHex"; $Result; "UTF-8") ]
                                                  • Set Variable [ $ContentLength; Value:Length($body) / 2 ]
                                                  • #build header
                                                  • Set Variable [ $text; Value:"HTTP/1.1 200 OK¶Server: MyServer 1.0¶Connection: close¶Content-Type: text/html¶Content-Length: " & $contentLength & "¶¶" ]
                                                  • Set Variable [ $text; Value:MBS( "Text.ReplaceNewline"; $Text; 3 ) ]
                                                  • Set Variable [ $r; Value:MBS("WebRequest.Send"; $WebRequest; $text & $result; "UTF-8") ]
                                                  • #give time to send answer
                                                  • Pause/Resume Script [ Duration (seconds): ,5 ]
                                                  • Set Variable [ $r; Value:MBS("WebRequest.Release"; $WebRequest) ]
                                                  • Exit Script [ ]
                                                  • End If
                                                  • End If
                                                  • #not handled
                                                  • Set Variable [ $r; Value:MBS("WebRequest.Release"; $WebRequest) ]
                                                  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: [WebHookReceived]
                                                          Script NameChange Answer
                                                          Run script with full access privilegesOff
                                                          Include In MenuNo
                                                          Layouts that use this script
                                                            Scripts that use this script
                                                              Script Definition
                                                              Script Steps
                                                              • Set Variable [ $text; Value:"HTTP/1.1 201 Created¶Server: MyServer 1.0¶Connection: close¶Content-Length: 0¶¶" ]
                                                              • Set Variable [ $text; Value:MBS( "Text.ReplaceNewline"; $Text; 3 ) ]
                                                              • Set Variable [ $r; Value:MBS("WebHook.SetAutoAnswer"; WebHook::Server Webhook; $text; "UTF-8") ]
                                                              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: WebHook to serve html

                                                                      Used functions: