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

MBS FileMaker Plugin Example Databases

Conditional Formatting

All examples are included with download of MBS FileMaker Plugin.

Conditional Formatting.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts5
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
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Conditional Formatting
6 fields defined, 1 record
Conditional Formatting

Fields

Table Name: Conditional Formatting - 6 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
PrimaryKeyNormal, TextAuto-Enter: 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:
                  • Creation account name
                  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:
                                  • Modification account name
                                  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
                                          OutputNormal, BinaryAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1

                                              Layout Objects: Conditional Formatting

                                              Regular Fields

                                              Field Name: Conditional Formatting::Output
                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                              • Top: 69 pt
                                              • Left: 82 pt
                                              • Bottom: 420 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
                                              No

                                              Buttons

                                              Button PropertiesCoordinatesScript/Script Step
                                                Type:
                                              • Text: highlighting cells that begin with the given text
                                              • Top: 75 pt
                                              • Left: 406 pt
                                              • Bottom: 109 pt
                                              • Right: 822 pt
                                              • Anchoring: Left, Top
                                              Perform Script [ “Test1” ]

                                              Scripts:


                                              Button PropertiesCoordinatesScript/Script Step
                                                Type:
                                              • Text: creating a gradated color scale on the cells
                                              • Top: 118 pt
                                              • Left: 406 pt
                                              • Bottom: 152 pt
                                              • Right: 822 pt
                                              • Anchoring: Left, Top
                                              Perform Script [ “Test2” ]

                                              Scripts:


                                              Button PropertiesCoordinatesScript/Script Step
                                                Type:
                                              • Text: highlighting cells that more than the specified value
                                              • Top: 161 pt
                                              • Left: 406 pt
                                              • Bottom: 195 pt
                                              • Right: 822 pt
                                              • Anchoring: Left, Top
                                              Perform Script [ “Test3” ]

                                              Scripts:


                                              Button PropertiesCoordinatesScript/Script Step
                                                Type:
                                              • Text: highlighting alternating rows
                                              • Top: 204 pt
                                              • Left: 406 pt
                                              • Bottom: 238 pt
                                              • Right: 822 pt
                                              • Anchoring: Left, Top
                                              Perform Script [ “Test4” ]

                                              Scripts:


                                              Script Hierarchy

                                              Test1
                                              Test2
                                              Test3
                                              Test4
                                              InitXL

                                              Next Script: [Test2]
                                              Script NameTest1
                                              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
                                                • #Conditional formatting: highlighting cells that begin With the given Text
                                                • #This example defines a conditional format with a bold font and sets conditional formatting for the range B3:B11 for highlighting cells that begin with 'a'.
                                                • If [ MBS("XL.IsInitialized") ≠ 1 ]
                                                • Perform Script [ “InitXL” ]
                                                • End If
                                                • #create new xlsx file
                                                • Set Variable [ $book; Value:MBS( "XL.NewBook"; 1 ) ]
                                                • Set Variable [ $sheet; Value:MBS("XL.Book.AddSheet"; $book; "my") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 2; 1; "Poltava") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 3; 1; "Athens") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 4; 1; "Thessaloniki") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 5; 1; "Kalamata") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 6; 1; "Amsterdam") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 7; 1; "Alexandroupolis") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 8; 1; "Kyiv") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 9; 1; "London") ]
                                                • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteText"; $book; $sheet; 10; 1; "New York") ]
                                                • #add conditional format
                                                • Set Variable [ $cFormat; Value:MBS("XL.Book.AddConditionalFormat"; $book) ]
                                                • #set font to be folder
                                                • Set Variable [ $font; Value:MBS("XL.ConditionalFormat.Font"; $book; $cFormat) ]
                                                • Set Variable [ $r; Value:MBS("XL.Font.SetBold"; $book; $font; 1) ]
                                                • Set Variable [ $cf; Value:MBS("XL.Sheet.addConditionalFormatting"; $book; $sheet) ]
                                                • Set Variable [ $r; Value:MBS("XL.ConditionalFormating.AddRange"; $book; $cf; 2; 10; 1; 1) ]
                                                • Set Variable [ $r; Value:MBS("XL.ConditionalFormating.AddRule"; $book; $cf; 0 /* BeginWith */; $cFormat; "a") ]
                                                • #save file
                                                • Set Field [ Conditional Formatting::Output; MBS("XL.Book.Save"; $book; "test1.xlsx") ]
                                                • Set Variable [ $r; Value:MBS("XL.Book.Release"; $book) ]
                                                • Export Field Contents [ Conditional Formatting::Output; “file:test1.xlsx”; Automatically open; Create folders:Yes ]
                                                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: [Test1]Next Script: [Test3]
                                                      Script NameTest2
                                                      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
                                                        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: [Test2]Next Script: [Test4]
                                                              Script NameTest3
                                                              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
                                                                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: [Test3]Next Script: [InitXL]
                                                                      Script NameTest4
                                                                      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
                                                                        • #Conditional formatting: highlighting alternating rows
                                                                        • #This example highlights alternating rows (banded rows) and makes the data in a worksheet easier to scan. It's possible to do this with the formula expression "=MOD(ROW(),2)=0" in a conditional formatting rule. If you want to alternate columns please use this formula: "=MOD(COLUMN(),2)=0".
                                                                        • If [ MBS("XL.IsInitialized") ≠ 1 ]
                                                                        • Perform Script [ “InitXL” ]
                                                                        • End If
                                                                        • #create new xlsx file
                                                                        • Set Variable [ $book; Value:MBS( "XL.NewBook"; 1 ) ]
                                                                        • Set Variable [ $sheet; Value:MBS("XL.Book.AddSheet"; $book; "my") ]
                                                                        • Set Variable [ $r; Value:MBS("XL.Book.SetRGBMode"; $book; 1) ]
                                                                        • #add conditional format
                                                                        • Set Variable [ $cFormat; Value:MBS("XL.Book.AddConditionalFormat"; $book) ]
                                                                        • Set Variable [ $r; Value:MBS("XL.ConditionalFormat.SetFillPattern"; $book; $cFormat; 1 /* solid */) ]
                                                                        • Set Variable [ $r; Value:MBS("XL.ConditionalFormat.SetPatternBackgroundColor"; $book; $cFormat; MBS("XL.Color.Pack"; $book; 240; 240; 240)) ]
                                                                        • Set Variable [ $cf; Value:MBS("XL.Sheet.addConditionalFormatting"; $book; $sheet) ]
                                                                        • Set Variable [ $r; Value:MBS("XL.ConditionalFormating.AddRange"; $book; $cf; 4; 20; 1; 10) ]
                                                                        • Set Variable [ $r; Value:MBS("XL.ConditionalFormating.AddRule"; $book; $cf; 6 /* Expression */; $cFormat; "=MOD(ROW(),2)=0") ]
                                                                        • #loop counting up from 1 to $count
                                                                        • Set Variable [ $count; Value:19 ]
                                                                        • Set Variable [ $row; Value:4 ]
                                                                        • Loop [ Flush: Always ]
                                                                        • Set Variable [ $col; Value:1 ]
                                                                        • Loop [ Flush: Always ]
                                                                        • Set Variable [ $r; Value:MBS("XL.Sheet.CellWriteNumber"; $book; $sheet; $row; $col; $row+$col) ]
                                                                        • #next
                                                                        • Set Variable [ $col; Value:$col + 1 ]
                                                                        • Exit Loop If [ $col > 9 ]
                                                                        • End Loop
                                                                        • Set Variable [ $row; Value:$row + 1 ]
                                                                        • Exit Loop If [ $row > $count ]
                                                                        • End Loop
                                                                        • #save file
                                                                        • Set Field [ Conditional Formatting::Output; MBS("XL.Book.Save"; $book; "test4.xlsx") ]
                                                                        • Set Variable [ $r; Value:MBS("XL.Book.Release"; $book) ]
                                                                        • Export Field Contents [ Conditional Formatting::Output; “file:test4.xlsx”; Automatically open; Create folders:Yes ]
                                                                        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: [Test4]
                                                                              Script NameInitXL
                                                                              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
                                                                                • #Find libXL and load it
                                                                                • #you can have libraries in container and export at runtime to folder of your choice.
                                                                                • #Or install library somewhere and pass path.
                                                                                • #If library is in same folder as plugin, you can only pass only file name.
                                                                                • If [ MBS("IsServer") ]
                                                                                • #Put the path you use for your server here:
                                                                                • If [ Get(SystemPlatform) = -2 ]
                                                                                • #Server on Windows
                                                                                • Set Variable [ $path; Value:"C:\Programs\FileMaker Server\libxl.dll" ]
                                                                                • Else If [ MBS("IsLinux") ]
                                                                                • #Server on Linux for FileMaker Cloud
                                                                                • Set Variable [ $path; Value:"/opt/FileMaker/FileMaker Server/libxl.so" ]
                                                                                • Else
                                                                                • #Server on Mac
                                                                                • Set Variable [ $path; Value: "/Library/FileMaker Server/libxl.dylib" ]
                                                                                • End If
                                                                                • Else
                                                                                • #For desktop and our examples we look in same folder as database:
                                                                                • Set Variable [ $databasePath; Value:Get(FilePath) ]
                                                                                • Set Variable [ $databasePath; Value:MBS("Path.FilemakerPathToNativePath"; $databasePath) ]
                                                                                • Set Variable [ $databasePath; Value:Substitute ( $databasePath ; ".fp7" ; ".fmp12") ]
                                                                                • Set Variable [ $databaseName; Value:Get(FileName) & ".fmp12" ]
                                                                                • If [ Get(SystemPlatform) = -2 ]
                                                                                • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "libxl.dll" ) ]
                                                                                • #plugin will look for libxl.dll and if not found also for libxl64.dll (64-bit) and libxl32.dll (32-bit).
                                                                                • Else
                                                                                • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "libxl.dylib" ) ]
                                                                                • #Mac dylib is usually 32 and 64 bit together.
                                                                                • End If
                                                                                • End If
                                                                                • #You can test for free.
                                                                                • #If you like to get a LibXL license, please follow links on our pricing page:
                                                                                • #https://www.monkeybreadsoftware.de/filemaker/pricing.shtml
                                                                                • Set Variable [ $LicenseeName; Value:"your name" ]
                                                                                • Set Variable [ $LicenseKey; Value:"your LibXL license key" ]
                                                                                • Set Variable [ $r; Value:MBS( "XL.Initialize"; $path; $LicenseeName; $LicenseKey) ]
                                                                                • If [ $r ≠ "OK" ]
                                                                                • Show Custom Dialog [ Title: "Error"; Message: $r; Default Button: “OK”, Commit: “No”; Button 2: “Cancel”, Commit: “No” ]
                                                                                • Halt Script
                                                                                • 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: Conditional Formatting

                                                                                              Used functions: