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

MBS FileMaker Plugin Example Databases

Create Container Preview

All examples are included with download of MBS FileMaker Plugin.

Create Container Preview.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
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Get Preview
10 fields defined, 0 record
Get Preview

Fields

Table Name: Get Preview - 10 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
                                          PreviewNormal, BinaryAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                              InputNormal, BinaryAuto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                                  File NameNormal, TextAuto-Enter: Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: None
                                                  • Automatically create indexes as needed
                                                  • Index Language: German
                                                        PreviewSizeNormal, TextAuto-Enter: Validation:
                                                        • Only during data entry
                                                        Storage:
                                                        • Repetitions: 1
                                                        • Indexing: None
                                                        • Automatically create indexes as needed
                                                        • Index Language: German
                                                              Made usingNormal, TextAuto-Enter:
                                                              • Allow editing
                                                              Validation:
                                                              • Only during data entry
                                                              Storage:
                                                              • Repetitions: 1
                                                              • Indexing: None
                                                              • Automatically create indexes as needed
                                                              • Index Language: German

                                                                  Layout Objects: Get Preview

                                                                  Regular Fields

                                                                  Field Name: Get Preview::Preview
                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                  • Top: 58 pt
                                                                  • Left: 563 pt
                                                                  • Bottom: 458 pt
                                                                  • Right: 963 pt
                                                                  • Anchoring: Right, Top and Bottom
                                                                  Field Format:
                                                                  • Edit Box
                                                                  Field Behavior:
                                                                  • Allow field to be entered: In Find mode, In Browse mode
                                                                  • Touch keyboard type: Default for Data Type
                                                                  • Go to next field using: Tab key
                                                                  No

                                                                  Field Name: Get Preview::Input
                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                  • Top: 58 pt
                                                                  • Left: 73 pt
                                                                  • Bottom: 458 pt
                                                                  • Right: 473 pt
                                                                  • Anchoring: Left and Right, Top and Bottom
                                                                  Field Format:
                                                                  • Edit Box
                                                                  Field Behavior:
                                                                  • Allow field to be entered: In Find mode, In Browse mode
                                                                  • Touch keyboard type: Default for Data Type
                                                                  • Go to next field using: Tab key
                                                                  No

                                                                  Field Name: Get Preview::File Name
                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                  • Top: 470 pt
                                                                  • Left: 161 pt
                                                                  • Bottom: 501 pt
                                                                  • Right: 414 pt
                                                                  • Anchoring: Left, 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

                                                                  Field Name: Get Preview::PreviewSize
                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                  • Top: 470 pt
                                                                  • Left: 667 pt
                                                                  • Bottom: 501 pt
                                                                  • Right: 920 pt
                                                                  • Anchoring: Right, 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

                                                                  Field Name: Get Preview::Made using
                                                                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                  • Top: 513 pt
                                                                  • Left: 667 pt
                                                                  • Bottom: 544 pt
                                                                  • Right: 920 pt
                                                                  • Anchoring: Right, 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: Import
                                                                  • Top: 103 pt
                                                                  • Left: 0 pt
                                                                  • Bottom: 134 pt
                                                                  • Right: 73 pt
                                                                  • Anchoring: Left, Top
                                                                  Perform Script [ “Import File” ]

                                                                  Scripts:


                                                                  Button PropertiesCoordinatesScript/Script Step
                                                                    Type:
                                                                  • Text: Generate
                                                                  • Top: 103 pt
                                                                  • Left: 473 pt
                                                                  • Bottom: 134 pt
                                                                  • Right: 563 pt
                                                                  • Anchoring: Right, Top
                                                                  Perform Script [ “Get Preview” ]

                                                                  Scripts:


                                                                  Script Hierarchy

                                                                  Get Preview
                                                                  Clear
                                                                  Import File
                                                                  Convert HEIC

                                                                  Next Script: [Clear]
                                                                  Script NameGet Preview
                                                                  Run script with full access privilegesOff
                                                                  Siri Shortcut VisibleOff
                                                                  Include In MenuYes
                                                                  Layouts that use this script
                                                                  Scripts that use this script
                                                                    Script Definition
                                                                    Script Steps
                                                                    • Set Variable [ $input; Value:Get Preview::Input ]
                                                                    • Set Variable [ $inputName; Value:GetAsText($input) ]
                                                                    • Set Variable [ $types; Value:MBS("Container.GetTypes"; $input) ]
                                                                    • Set Field [ Get Preview::Preview; "" ]
                                                                    • If [ IsEmpty ( $input ) ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • If [ 1 ]
                                                                    • #Try FileMaker itself
                                                                    • Set Variable [ $preview; Value:GetThumbnail ( Get Preview::Input ; 1000 ; 1000 ) ]
                                                                    • If [ Get(LastError) = 0 and $preview ≠ "?" ]
                                                                    • Set Field [ Get Preview::Preview; $preview ]
                                                                    • Set Field [ Get Preview::Made using; "FileMaker" ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • End If
                                                                    • If [ 1 ]
                                                                    • #Try plugin to read more formats known by OS
                                                                    • Set Variable [ $imageData; Value:MBS( "Container.ReadImage"; $input; "PNG"; "image.png") ]
                                                                    • If [ MBS("IsError") = 0 and not IsEmpty ( $imageData ) ]
                                                                    • #scale down?
                                                                    • Set Variable [ $image; Value:MBS( "GMImage.NewFromContainer"; $imageData) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • #limit size to 1000 pixel maximum
                                                                    • Set Variable [ $scale; Value:MBS("GMImage.Scale";$Image; "1000>") ]
                                                                    • #remove metadata
                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetProfile"; $image; "IPTC"; "" ) ]
                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetProfile"; $image; "EXIF"; "" ) ]
                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetProfile"; $image; "XMP"; "" ) ]
                                                                    • #save
                                                                    • Set Variable [ $NewImage; Value:MBS("GMImage.WriteToJPEGContainer"; $Image) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $NewImage ]
                                                                    • Set Field [ Get Preview::Made using; "ReadImage" ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • Set Variable [ $r; Value:MBS("GMimage.Release";$Image) ]
                                                                    • End If
                                                                    • Set Field [ Get Preview::Preview; $imageData ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • End If
                                                                    • Set Variable [ $CouldBePDF; Value:Position($types; "PDF";1;1) > 0 or Position($inputName; ".pdf";1;1) > 0 ]
                                                                    • Set Variable [ $CouldBeVideo; Value:Position($types; "m4v";1;1) > 0 or Position($inputName; ".m4v";1;1) > 0 or Position($inputName; ".mov";1;1) > 0 or Position($inputName; ".mpeg";1;1) > 0 or Position($inputName; ".mpg";1;1) > 0 ]
                                                                    • If [ 1 ]
                                                                    • #Try GraphicsMagick for more formats
                                                                    • If [ not $CouldBePDF and not $CouldBeVideo ]
                                                                    • Set Variable [ $image; Value:MBS( "GMImage.NewFromContainer"; $input) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • #limit size to 1000 pixel maximum
                                                                    • Set Variable [ $scale; Value:MBS("GMImage.Scale";$Image; "1000>") ]
                                                                    • #remove metadata
                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetProfile"; $image; "IPTC"; "" ) ]
                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetProfile"; $image; "EXIF"; "" ) ]
                                                                    • Set Variable [ $r; Value:MBS( "GMImage.SetProfile"; $image; "XMP"; "" ) ]
                                                                    • #save
                                                                    • Set Variable [ $NewImage; Value:MBS("GMImage.WriteToJPEGContainer"; $Image) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $NewImage ]
                                                                    • Set Field [ Get Preview::Made using; "GraphicsMagick" ]
                                                                    • Set Variable [ $r; Value:MBS("GMimage.Release";$Image) ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • Set Variable [ $r; Value:MBS("GMimage.Release";$Image) ]
                                                                    • End If
                                                                    • End If
                                                                    • End If
                                                                    • If [ 1 ]
                                                                    • #try PDF
                                                                    • If [ $CouldBePDF ]
                                                                    • If [ MBS("IsWindows") ]
                                                                    • Set Variable [ $pdf; Value:MBS( "WinPDF.LoadContainer"; Get Preview::Input) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Variable [ $NewImage; Value:MBS( "WinPDF.PageImageAtSize"; $pdf; 0; 0; 600; "JPEG"; "page.jpg") ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $NewImage ]
                                                                    • Set Field [ Get Preview::Made using; "WinPDF" ]
                                                                    • Set Variable [ $r; Value:MBS( "WinPDF.Release"; $pdf) ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • Set Variable [ $r; Value:MBS( "WinPDF.Release"; $pdf) ]
                                                                    • End If
                                                                    • Else If [ MBS("IsMacOS") or MBS("IsIOS") ]
                                                                    • Set Variable [ $preview; Value:MBS( "PDFKit.GetPDFPageImage"; $Input; 0; "JPEG"; "input.jpg"; 72) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $preview ]
                                                                    • Set Field [ Get Preview::Made using; "PDFKit" ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • End If
                                                                    • #DynaPDF, if initialized?
                                                                    • If [ MBS("DynaPDF.IsInitialized") ]
                                                                    • #Clear current PDF document
                                                                    • Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
                                                                    • #Render one page as Picture
                                                                    • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Get Preview::Input) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Variable [ $r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; 1) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • #now render
                                                                    • Set Variable [ $image; Value:MBS("DynaPDF.RenderPage"; $pdf; 1; 72) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $image ]
                                                                    • Set Field [ Get Preview::Made using; "DynaPDF" ]
                                                                    • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • End If
                                                                    • End If
                                                                    • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                                                                    • End If
                                                                    • End If
                                                                    • End If
                                                                    • If [ 1 ]
                                                                    • #try quickLook functions
                                                                    • Set Variable [ $fpath; Value:GetAsText($input) ]
                                                                    • If [ Position ( $fpath ; "/" ; 1 ; 1 ) > 0 ]
                                                                    • Set Variable [ $path; Value:MBS( "Path.FileMakerPathToNativePath"; $fpath) ]
                                                                    • If [ Length ( $path ) > 0 ]
                                                                    • Set Variable [ $image; Value:MBS( "Icon.GetIconWithQuickLook"; $path; 512; 1 ) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $image ]
                                                                    • Set Field [ Get Preview::Made using; "QuickLook File" ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • End If
                                                                    • Else If [ Position ( $types ; "FNAM" ; 1 ; 1 ) > 0 ]
                                                                    • #write temp file
                                                                    • Set Variable [ $path; Value:MBS( "Path.AddPathComponent"; MBS( "Folders.UserTemporary" ); $fpath) ]
                                                                    • Set Variable [ $r; Value:MBS("Container.WriteFile"; $input; $path) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Variable [ $image; Value:MBS( "Icon.GetIconWithQuickLook"; $path; 512; 1 ) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $image ]
                                                                    • Set Field [ Get Preview::Made using; "QuickLook Container" ]
                                                                    • Set Variable [ $r; Value:MBS("Files.Delete"; $path) ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • Set Variable [ $r; Value:MBS("Files.Delete"; $path) ]
                                                                    • End If
                                                                    • End If
                                                                    • End If
                                                                    • If [ 1 ]
                                                                    • #try video via AVAsset functions
                                                                    • If [ $CouldBeVideo ]
                                                                    • Set Variable [ $asset; Value:MBS( "AVAsset.OpenContainer"; $input ) ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Variable [ $image; Value:MBS( "AVAsset.Image"; $asset; 10; "jpeg"; "preview.jpg") ]
                                                                    • If [ MBS("IsError") = 0 ]
                                                                    • Set Field [ Get Preview::Preview; $image ]
                                                                    • Set Field [ Get Preview::Made using; "AVAsset" ]
                                                                    • Set Variable [ $r; Value:MBS( "AVAsset.Release"; $asset ) ]
                                                                    • Exit Script [ ]
                                                                    • End If
                                                                    • Set Variable [ $r; Value:MBS( "AVAsset.Release"; $asset ) ]
                                                                    • End If
                                                                    • 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: [Get Preview]Next Script: [Import File]
                                                                            Script NameClear
                                                                            Run script with full access privilegesOff
                                                                            Siri Shortcut VisibleOff
                                                                            Include In MenuYes
                                                                            Layouts that use this script
                                                                              Scripts that use this script
                                                                                Script Definition
                                                                                Script Steps
                                                                                • Delete All Records [ 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]Next Script: [Convert HEIC]
                                                                                              Script NameImport File
                                                                                              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
                                                                                                • If [ Get(FoundCount) = 0 ]
                                                                                                • New Record/Request
                                                                                                • End If
                                                                                                • Insert File [ Get Preview::Input ] [ Storage method: Let user choose ] [ Display icon ] [ Compression: Never compress ]
                                                                                                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: [Import File]
                                                                                                        Script NameConvert HEIC
                                                                                                        Run script with full access privilegesOff
                                                                                                        Siri Shortcut VisibleOff
                                                                                                        Include In MenuYes
                                                                                                        Layouts that use this script
                                                                                                          Scripts that use this script
                                                                                                            Script Definition
                                                                                                            Script Steps
                                                                                                            • Set Field [ Get Preview::Preview; Get Preview::Input ]
                                                                                                            • Commit Records/Requests [ No dialog ]
                                                                                                            • If [ IsEmpty ( Get Preview::Input ) ]
                                                                                                            • #ignore
                                                                                                            • Else
                                                                                                            • #check filename
                                                                                                            • Set Variable [ $name; Value:GetAsText ( Get Preview::Input ) ]
                                                                                                            • Set Variable [ $name; Value:GetValue($name; 1) ]
                                                                                                            • Set Variable [ $extension; Value:Right ( $name ; 5 ) ]
                                                                                                            • If [ $extension = ".heif" or $extension = ".heic" ]
                                                                                                            • #we got a HEIF image
                                                                                                            • #get new file name
                                                                                                            • Set Variable [ $name; Value:Substitute($name; ".heif"; ".png") ]
                                                                                                            • Set Variable [ $name; Value:Substitute($name; ".heic"; ".png") ]
                                                                                                            • Set Variable [ $name; Value:Substitute($name; ".jpg"; ".png") ]
                                                                                                            • #now convert to PNG
                                                                                                            • Set Variable [ $image; Value:MBS( "Container.ReadImage"; Get Preview::Input; "PNG"; $name ) ]
                                                                                                            • If [ MBS("IsError") = 0 ]
                                                                                                            • #save on success to container
                                                                                                            • Set Field [ Get Preview::Preview; $image ]
                                                                                                            • Commit Records/Requests [ No dialog ]
                                                                                                            • Else
                                                                                                            • #log error?
                                                                                                            • End If
                                                                                                            • Else If [ Right ( $name ; 4 ) = ".pdf" ]
                                                                                                            • #skip PDF
                                                                                                            • Else If [ Right ( $name ; 4 ) = ".jpg" ]
                                                                                                            • #jpg, which may not be a jpeg, but a mislabled heic
                                                                                                            • #try to load the jpeg
                                                                                                            • Set Variable [ $image; Value:MBS( "GMImage.NewFromContainer"; Get Preview::Input) ]
                                                                                                            • If [ MBS("IsError") = 0 ]
                                                                                                            • #it is a jpeg or png!
                                                                                                            • Set Variable [ $r; Value:MBS( "GMImage.Release"; $image) ]
                                                                                                            • Else
                                                                                                            • #it is a heic?
                                                                                                            • Set Variable [ $name; Value:Substitute($name; ".heif"; ".png") ]
                                                                                                            • Set Variable [ $name; Value:Substitute($name; ".heic"; ".png") ]
                                                                                                            • Set Variable [ $name; Value:Substitute($name; ".jpg"; ".png") ]
                                                                                                            • #now convert to PNG
                                                                                                            • Set Variable [ $image; Value:MBS( "Container.ReadImage"; Get Preview::Input; "PNG"; $name ) ]
                                                                                                            • If [ MBS("IsError") = 0 ]
                                                                                                            • #save on success to container
                                                                                                            • Set Field [ Get Preview::Preview; $image ]
                                                                                                            • Commit Records/Requests [ No dialog ]
                                                                                                            • Else
                                                                                                            • #log error?
                                                                                                            • End If
                                                                                                            • End If
                                                                                                            • 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

                                                                                                                    Download example: Create Container Preview

                                                                                                                    Used functions: