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

MBS FileMaker Plugin Example Databases

Barcode Generation JSON

All examples are included with download of MBS FileMaker Plugin.

Barcode Generation JSON.fmp12

Overview
Tables 1
Relationships 0
Layouts 1
Scripts 9
Value Lists 0
Custom Functions 0
Custom Menus 24
File Options
Default custom menu set [Standard FileMaker Menus]
Default theme Visionär
When opening file
Minimum allowed version 12.0
Login using Account Name; Account= Admin
Allow user to save password Off
Require iOS passcode Off
Show Sign-in fields Off
Switch to layout Off
Hide all toolbars Off
Script triggers
OnFirstWindowOpen Off
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
Barcode Generation JSON
3 fields defined, 11 records
Barcode Generation JSON

Fields

Table Name: Barcode Generation JSON - 3 Fields
Field Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
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
        JSON Normal, Text Auto-Enter:
        • Allow editing
        Validation:
        • Only during data entry
        Storage:
        • Repetitions: 1
        • Indexing: None
        • Automatically create indexes as needed
        • Index Language: German
            Image Normal, Binary Auto-Enter:
            • Allow editing
            Validation:
            • Only during data entry
            Storage:
            • Repetitions: 1

                Layout Objects: Barcode Generation JSON

                Regular Fields

                Field Name: Barcode Generation JSON::Description
                Field Properties Coordinates Field Format Field Behavior Quick Find
                • Top: 52 pt
                • Left: 138 pt
                • Bottom: 73 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: Barcode Generation JSON::JSON
                Field Properties Coordinates Field Format Field Behavior Quick Find
                • Top: 75 pt
                • Left: 138 pt
                • Bottom: 288 pt
                • Right: 508 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: Barcode Generation JSON::Image
                Field Properties Coordinates Field Format Field Behavior Quick Find
                • Top: 59 pt
                • Left: 645 pt
                • Bottom: 288 pt
                • Right: 1015 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

                Buttons

                Button Properties Coordinates Script/Script Step
                  Type:
                • Text: Format JSON
                • Top: 75 pt
                • Left: 519 pt
                • Bottom: 107 pt
                • Right: 634 pt
                • Anchoring: Left, Top
                Perform Script [ “Format JSON” ]

                Scripts:


                Button Properties Coordinates Script/Script Step
                  Type:
                • Text: Generate Barcode
                • Top: 128 pt
                • Left: 519 pt
                • Bottom: 160 pt
                • Right: 634 pt
                • Anchoring: Left, Top
                Perform Script [ “Run” ]

                Scripts:


                Script Hierarchy

                Format JSON
                Run
                Clear Images
                -
                Create Barcode
                Create Barcode on Server
                Barcode Test
                -
                Create Barcode with circles

                Next Script: [Run]
                Script Name Format JSON
                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 [ $json; Value:MBS("JSON.Format"; Barcode Generation JSON::JSON) ]
                  • If [ MBS("IsError") = 0 ]
                  • Set Variable [ $json; Value:MBS("JSON.Colorize"; $json) ]
                  • If [ MBS("IsError") = 0 ]
                  • Set Field [ Barcode Generation JSON::JSON; $json ]
                  • 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 JSON] Next Script: [Clear Images]
                          Script Name Run
                          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 Field [ Barcode Generation JSON::Image; "" ]
                            • Set Variable [ $img; Value:MBS("Barcode.GenerateJSON"; Barcode Generation JSON::JSON) ]
                            • If [ MBS("IsError") = 0 ]
                            • Set Field [ Barcode Generation JSON::Image; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png") ]
                            • Set Variable [ $r; Value:MBS( "GMImage.Destroy"; $img ) ]
                            • Else [ ]
                            • Show Custom Dialog [ Title: "Failed to create barcode"; Message: $img; 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: [Run] Next Script: [-]
                                    Script Name Clear Images
                                    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
                                        • Replace Field Contents [ Barcode Generation JSON::Image; 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: [Clear Images] Next Script: [Create Barcode]
                                                Script Name -
                                                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
                                                      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: [-] Next Script: [Create Barcode on Server]
                                                                    Script Name Create Barcode
                                                                    Run script with full access privileges Off
                                                                    Siri Shortcut Visible Off
                                                                    Include In Menu No
                                                                    Layouts that use this script
                                                                      Scripts that use this script
                                                                      Script Definition
                                                                      Script Steps
                                                                      • #This script is run locally in FileMaker Pro or Go to create barcode via server
                                                                      • Set Variable [ $JSON; Value:Get(ScriptParameter) ]
                                                                      • Set Variable [ $result; Value:"" ]
                                                                      • If [ GetAsText(MBS("Version")) = "?" ]
                                                                      • #no MBS Plugin, so pass to server
                                                                      • Perform Script on Server [ “Create Barcode on Server”; Parameter: $JSON ] [ Wait for completion ]
                                                                      • Set Variable [ $errorCode; Value:Get(LastError) ]
                                                                      • If [ $errorCode ≠ 0 ]
                                                                      • #report error back to caller
                                                                      • Set Variable [ $error; Value:"Failed to trigger script on server with error " & $errorCode ]
                                                                      • Set Variable [ $result; Value:JSONSetElement ( $JSON ; "error" ; $error; JSONString ) ]
                                                                      • Else [ ]
                                                                      • #pass result back to caller
                                                                      • Set Variable [ $result; Value:Get(ScriptResult) ]
                                                                      • End If
                                                                      • Else [ ]
                                                                      • #with MBS Plugin
                                                                      • Perform Script [ “Create Barcode on Server”; Parameter: $JSON ]
                                                                      • Set Variable [ $result; Value:Get(ScriptResult) ]
                                                                      • End If
                                                                      • Exit Script [ Result: $result ]
                                                                      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: [Create Barcode] Next Script: [Barcode Test]
                                                                                  Script Name Create Barcode on Server
                                                                                  Run script with full access privileges Off
                                                                                  Siri Shortcut Visible Off
                                                                                  Include In Menu No
                                                                                  Layouts that use this script
                                                                                    Scripts that use this script
                                                                                    Script Definition
                                                                                    Script Steps
                                                                                    • #This script is run on server to provide barcode to clients without MBS Plugin
                                                                                    • Set Variable [ $JSON; Value:Get(ScriptParameter) ]
                                                                                    • Set Variable [ $result; Value:"" ]
                                                                                    • If [ GetAsText(MBS("Version")) = "?" ]
                                                                                    • #no MBS Plugin
                                                                                    • Set Variable [ $result; Value:JSONSetElement ( $JSON ; "error" ; "No MBS Plugin on server installed."; JSONString ) ]
                                                                                    • Else [ ]
                                                                                    • #with MBS Plugin
                                                                                    • #generate barcode based on JSON
                                                                                    • Set Variable [ $img; Value:MBS("Barcode.GenerateJSON"; $JSON) ]
                                                                                    • If [ MBS("IsError") = 0 ]
                                                                                    • #Create PNG image file as container value
                                                                                    • Set Variable [ $Image; Value:MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png") ]
                                                                                    • If [ MBS("IsError") = 0 ]
                                                                                    • #Return image base64 encoded
                                                                                    • Set Variable [ $result; Value:JSONSetElement ( $JSON ; "barcode" ; Base64Encode ( $Image ); JSONString ) ]
                                                                                    • Else [ ]
                                                                                    • #Pass back error
                                                                                    • Set Variable [ $result; Value:JSONSetElement ( $JSON ; "error" ; $Image; JSONString ) ]
                                                                                    • End If
                                                                                    • #free memory
                                                                                    • Set Variable [ $r; Value:MBS( "GMImage.Destroy"; $img ) ]
                                                                                    • Else [ ]
                                                                                    • #Pass back error
                                                                                    • Set Variable [ $result; Value:JSONSetElement ( $JSON ; "error" ; $img; JSONString ) ]
                                                                                    • End If
                                                                                    • End If
                                                                                    • Exit Script [ Result: $result ]
                                                                                    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: [Create Barcode on Server] Next Script: [-]
                                                                                                  Script Name Barcode Test
                                                                                                  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
                                                                                                      • #Build JSON to call
                                                                                                      • Set Variable [ $JSON; Value:Barcode Generation JSON::JSON ]
                                                                                                      • // Set Variable [ $JSON; Value:JSONSetElement ( "{}" ; "symbology" ; "QRCode"; JSONString ) ]
                                                                                                      • // Set Variable [ $JSON; Value:JSONSetElement ( $JSON ; "Text" ; "Hello World"; JSONString ) ]
                                                                                                      • // Set Variable [ $JSON; Value:JSONSetElement ( $JSON ; "Scale" ; "4"; JSONNumber ) ]
                                                                                                      • #run script to create barcode
                                                                                                      • Perform Script [ “Create Barcode”; Parameter: $JSON ]
                                                                                                      • Set Variable [ $value; Value:Get(ScriptResult) ]
                                                                                                      • #check result
                                                                                                      • Set Variable [ $barcode; Value:JSONGetElement ( $value ; "barcode" ) ]
                                                                                                      • If [ Length ( $barcode ) > 0 ]
                                                                                                      • Set Field [ Barcode Generation JSON::Image; Base64Decode ( $barcode; "barcode.png" ) ]
                                                                                                      • Else [ ]
                                                                                                      • Set Variable [ $error; Value:JSONGetElement ( $value ; "error" ) ]
                                                                                                      • Show Custom Dialog [ Title: "Failed to create barcode"; Message: $error; 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: [Barcode Test] Next Script: [Create Barcode with circles]
                                                                                                            Script Name -
                                                                                                            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
                                                                                                                  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: [-]
                                                                                                                                Script Name Create Barcode with circles
                                                                                                                                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
                                                                                                                                    • #Special script for QRCode to output dots as circles
                                                                                                                                    • Set Field [ Barcode Generation JSON::Image; "" ]
                                                                                                                                    • Set Variable [ $options; Value:Barcode Generation JSON::JSON ]
                                                                                                                                    • Set Variable [ $options; Value:JSONSetElement ( $options; "OutputJSON" ; 1 ; JSONBoolean ) ]
                                                                                                                                    • Set Variable [ $options; Value:JSONSetElement ( $options; "Scale" ; 4 ; JSONNumber ) ]
                                                                                                                                    • Set Variable [ $json; Value:MBS("Barcode.GenerateJSON"; $options) ]
                                                                                                                                    • Set Variable [ $$json; Value:$json ]
                                                                                                                                    • If [ MBS("IsError") = 0 ]
                                                                                                                                    • Set Variable [ $Border; Value:10 ]
                                                                                                                                    • Set Variable [ $Scale; Value:JSONGetElement ( $options ; "Scale" ) ]
                                                                                                                                    • Set Variable [ $width; Value:JSONGetElement ( $json ; "width" ) + 2 * $Border ]
                                                                                                                                    • Set Variable [ $height; Value:JSONGetElement ( $json ; "height" ) + 2 * $Border ]
                                                                                                                                    • If [ $width > 2000 or $height > 2000 ]
                                                                                                                                    • Show Custom Dialog [ Title: "Huge picture?"; Message: $width & "x" & $height; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                                                                                    • Exit Script [ ]
                                                                                                                                    • End If
                                                                                                                                    • Set Variable [ $img; Value:MBS( "GMImage.New"; $width & "x" & $height; "white") ]
                                                                                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetStrokeColor"; $img; "black") ]
                                                                                                                                    • #we only do rectangles here, no circles, strings or hexagons
                                                                                                                                    • Set Variable [ $rectangles; Value:JSONGetElement ( $json ; "rectangles" ) ]
                                                                                                                                    • Set Variable [ $count; Value:MBS("JSON.GetArraySize"; $rectangles) ]
                                                                                                                                    • Set Variable [ $index; Value:0 ]
                                                                                                                                    • If [ $index ≤ $count ]
                                                                                                                                    • Loop [ Flush: Defer ]
                                                                                                                                    • #your script steps here
                                                                                                                                    • Set Variable [ $item; Value:MBS("JSON.GetArrayItem"; $rectangles; $index) ]
                                                                                                                                    • Set Variable [ $width; Value:GetAsNumber( JSONGetElement ( $item; "width" )) ]
                                                                                                                                    • Set Variable [ $height; Value:GetAsNumber( JSONGetElement ( $item; "height" )) ]
                                                                                                                                    • Set Variable [ $x; Value:JSONGetElement ( $item; "x" ) + $Border ]
                                                                                                                                    • Set Variable [ $y; Value:JSONGetElement ( $item; "y" ) + $Border ]
                                                                                                                                    • #we could draw round recangles
                                                                                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetFillColor"; $img; "black") ]
                                                                                                                                    • // Set Variable [ $r; Value:MBS( "GMImage.DrawRoundRectangle"; $img; $x; $y; $x + $width; $y + $height; $Scale; $Scale ) ]
                                                                                                                                    • #or draw circles
                                                                                                                                    • Set Variable [ $step; Value:$scale * 2 ]
                                                                                                                                    • Set Variable [ $iy; Value:0 ]
                                                                                                                                    • Loop [ Flush: Defer ]
                                                                                                                                    • Set Variable [ $ix; Value:0 ]
                                                                                                                                    • Loop [ Flush: Defer ]
                                                                                                                                    • #your script steps here
                                                                                                                                    • Set Variable [ $r; Value:MBS( "GMImage.DrawCircle"; $img; $x + $ix + $step/2; // circle center $y + $iy + $step/2; $x + $ix + $step; // and perimeter point $y + $iy + $step/2) ]
                                                                                                                                    • #next
                                                                                                                                    • Set Variable [ $ix; Value:$ix + $step ]
                                                                                                                                    • Exit Loop If [ $ix ≥ $width ]
                                                                                                                                    • End Loop
                                                                                                                                    • #next
                                                                                                                                    • Set Variable [ $iy; Value:$iy + $step ]
                                                                                                                                    • Exit Loop If [ $iy ≥ $height ]
                                                                                                                                    • End Loop
                                                                                                                                    • #next
                                                                                                                                    • Set Variable [ $index; Value:$index + 1 ]
                                                                                                                                    • Exit Loop If [ $index ≥ $count ]
                                                                                                                                    • End Loop
                                                                                                                                    • End If
                                                                                                                                    • Set Field [ Barcode Generation JSON::Image; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png") ]
                                                                                                                                    • Set Variable [ $r; Value:MBS( "GMImage.Destroy"; $img ) ]
                                                                                                                                    • Else [ ]
                                                                                                                                    • Show Custom Dialog [ Title: "Failed to create barcode"; Message: $json; 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

                                                                                                                                            Download example: Barcode Generation JSON

                                                                                                                                            Used functions: