MBS FileMaker Plugin Example Databases

Create Sort Script

All examples are included with download of MBS FileMaker Plugin.

Create Sort Script.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts4
Value Lists0
Custom Functions0
Custom Menus0
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
Create Sort Script
4 fields defined, 1 record
Create Sort Script

Fields

Table Name: Create Sort Script - 4 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
FileNameNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      TableNameNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          XMLNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              FieldsNormal, TextAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German

                  Layout Objects: Create Sort Script

                  Regular Fields

                  Field Name: Create Sort Script::FileName
                  Field PropertiesCoordinatesField FormatField BehaviorQuick 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: Create Sort Script::TableName
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 75 pt
                  • Left: 138 pt
                  • Bottom: 96 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: Create Sort Script::Fields
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 98 pt
                  • Left: 138 pt
                  • Bottom: 520 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: Create Sort Script::XML
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 99 pt
                  • Left: 453 pt
                  • Bottom: 520 pt
                  • Right: 1016 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

                  Group Buttons

                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Example file included with MBS FileMaker Plugin.
                    Additional Properties:
                  • Rectangular
                  • Top: 545 pt
                  • Left: 25 pt
                  • Bottom: 566 pt
                  • Right: 336 pt
                  • Anchoring: Left, Top
                  Open URL [ "https://www.monkeybreadsoftware.com/filemaker/" ] [ No dialog ]

                  Buttons

                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Get Field List
                  • Top: 52 pt
                  • Left: 454 pt
                  • Bottom: 88 pt
                  • Right: 599 pt
                  • Anchoring: Left, Top
                  Perform Script [ “Get Field List” ]

                  Scripts:


                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Generate XML
                  • Top: 52 pt
                  • Left: 616 pt
                  • Bottom: 88 pt
                  • Right: 761 pt
                  • Anchoring: Left, Top
                  Perform Script [ “Generate XML” ]

                  Scripts:


                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Copy To Clipboard
                  • Top: 52 pt
                  • Left: 778 pt
                  • Bottom: 88 pt
                  • Right: 923 pt
                  • Anchoring: Left, Top
                  Perform Script [ “Copy To Clipboard” ]

                  Scripts:


                  Script Hierarchy

                  Get Field List
                  Generate XML
                  Copy To Clipboard
                  Clear

                  Next Script: [Generate XML]
                  Script NameGet Field List
                  Run script with full access privilegesOff
                  Include In MenuYes
                  Layouts that use this script
                  Scripts that use this script
                    Script Definition
                    Script Steps
                    • #get field list without globals or summary fields
                    • Set Variable [ $list; Value:MBS( "FM.ExecuteFileSQL"; Create Sort Script::FileName; "SELECT FieldName, FieldID FROM FileMaker_Fields WHERE TableName = ? AND NOT (FieldType LIKE '%global%' OR FieldClass LIKE '%Summary%')" ; 9; 13; Create Sort Script::TableName ) ]
                    • If [ MBS("IsError") ]
                    • Show Custom Dialog [ Title: "Failed to query"; Message: $list; Default Button: “OK”, Commit: “Yes” ]
                    • Else
                    • Set Field [ Create Sort Script::Fields; $list ]
                    • 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: [Get Field List]Next Script: [Copy To Clipboard]
                            Script NameGenerate XML
                            Run script with full access privilegesOff
                            Include In MenuYes
                            Layouts that use this script
                            Scripts that use this script
                              Script Definition
                              Script Steps
                              • Set Variable [ $xmlPre; Value:"<fmxmlsnippet type=\"FMObjectList\"><Step enable=\"True\" id=\"141\" name=\"Set Variable\"><Value><Calculation><![CDATA[Get(ScriptParameter)]]></Calculation></Value><Repetition><Calculation><![CDATA[1]]></Calculation></Repetition><Name>$sortBy</Name></Step>¶<Step enable=\"True\" id=\"68\" name=\"If\"><Calculation><![CDATA[$sortBy = \"\"]]></Calculation></Step><Step enable=\"True\" id=\"89\" name=\"# (comment)\"><Text>nothing to do</Text></Step>¶" ]
                              • Set Variable [ $xmlPost; Value:"<Step enable=\"True\" id=\"70\" name=\"End If\"></Step>¶</fmxmlsnippet>" ]
                              • Set Variable [ $xmlTemplate; Value:"<Step enable=\"True\" id=\"125\" name=\"Else If\"><Calculation><![CDATA[$sortBy = \"FieldName\"]]></Calculation></Step>¶<Step enable=\"True\" id=\"39\" name=\"Sort Records\"><NoInteract state=\"True\"></NoInteract><Restore state=\"True\"></Restore><SortList Maintain=\"True\" value=\"True\"><Sort type=\"Ascending\"><PrimaryField><Field table=\"TableName\" id=\"FieldID\" name=\"FieldName\"></Field></PrimaryField></Sort></SortList></Step>¶" ]
                              • Set Variable [ $xml; Value:$xmlPre ]
                              • Set Variable [ $fields; Value:Create Sort Script::Fields ]
                              • Set Variable [ $count; Value:ValueCount ( $fields ) ]
                              • Set Variable [ $index; Value:1 ]
                              • If [ $index ≤ $count ]
                              • Loop
                              • #your script steps here
                              • Set Variable [ $line; Value:Substitute(GetValue($fields; $index); Char(9); ¶) ]
                              • Set Variable [ $name; Value:GetValue($line; 1) ]
                              • Set Variable [ $id; Value:GetValue($line; 2) ]
                              • Set Variable [ $x; Value:Substitute(Substitute(Substitute($xmlTemplate; "FieldName"; $name); "FieldID"; $id); "TableName"; Create Sort Script::TableName) ]
                              • Set Variable [ $xml; Value:$xml & $x ]
                              • #next
                              • Set Variable [ $index; Value:$index + 1 ]
                              • Exit Loop If [ $index > $count ]
                              • End Loop
                              • End If
                              • Set Variable [ $xml; Value:$xml & $xmlPost ]
                              • Set Field [ Create Sort Script::XML; $xml ]
                              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: [Generate XML]Next Script: [Clear]
                                      Script NameCopy To Clipboard
                                      Run script with full access privilegesOff
                                      Include In MenuYes
                                      Layouts that use this script
                                      Scripts that use this script
                                        Script Definition
                                        Script Steps
                                        • #Copy to clipboard, so you can paste in script editor
                                        • Set Variable [ $r; Value:MBS( "Clipboard.SetFileMakerData"; "ScriptStep"; Create Sort Script::XML ) ]
                                        • If [ MBS("IsError") ]
                                        • Show Custom Dialog [ Title: "Failed to set clipboard"; 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: [Copy To Clipboard]
                                                Script NameClear
                                                Run script with full access privilegesOff
                                                Include In MenuYes
                                                Layouts that use this script
                                                  Scripts that use this script
                                                    Script Definition
                                                    Script Steps
                                                    • Set Field [ Create Sort Script::Fields; "" ]
                                                    • Set Field [ Create Sort Script::XML; "" ]
                                                    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: Create Sort Script

                                                            Used functions:




                                                            Links
                                                            MBS FileMaker Plugins