« Three weeks till year… | Home | MBS FileMaker Plugin,… »

MBS FileMaker Plugin Update Check Script

Today we had the need to write a script to update or install MBS FileMaker Plugin. Often developers put plugin files in containers in a special MBS table in their solution on a server. Now if client opens database, the plugin may need to be installed or updated on the client. So we check a few cases here and made sure script runs well if plugin is not installed.

Check If Update is Needed:

 

# Check what plugin version we have here in the database:

Go to Layout [ “Install Plugin Update if needed” ]

Go to Record/Request/Page [ First ]

 

Set Variable [ $DatabaseVersion ; Value: GetAsNumber(Install Plugin Update if needed::Version Number) ] 

Set Variable [ $InstalledVersion ; Value: GetAsNumber(MBS("VersionAutoUpdate")) ] 

Set Variable [ $InstalledVersionText ; Value: GetAsText(MBS("Version")) ] 

 

If [ GetAsNumber($InstalledVersion) = "?" ] 

# not installed

Show Custom Dialog [ "MBS Plugin is not installed. Can we install version " & Install Plugin Update if needed::Version D…" ] 

If [  Get ( LastMessageChoice ) = 1 ] 

Perform Script [ “Install MBS Plugin” ]

End If

Else If [ $InstalledVersion = $DatabaseVersion ] 

# current version

Show Custom Dialog [ "Already up to date" ] 

Else If [ $InstalledVersion > $DatabaseVersion ] 

# newer version

Show Custom Dialog [ "Already up to date. Installed version " & $InstalledVersionText & " is newer than version " & Inst…" ] 

Else

# found update

Show Custom Dialog [ "Newer Version " & Install Plugin Update if needed::Version Display & " is available. Install now?"… ] 

If [  Get ( LastMessageChoice ) = 1 ] 

Perform Script [ “Install MBS Plugin” ]

End If

End If

 

# go to fields to update them

Go to Field [ Install Plugin Update if needed::MBS Installed ] 

Go to Field [ Install Plugin Update if needed::MBS Installed Version ] 

Go to Field [ Install Plugin Update if needed::MBS Installed Version Number ] 

Commit Records/Requests [ Skip data entry validation ; No dialog ] 

 

 

 

Skript: Install MBS Plugin

 

#  Check Architecture

#  will be ? for older 32-bit FileMaker Pro

Set Variable [ $Arch ; Value: GetAsText( Get (ApplicationArchitecture)) ] 

#  Check Platform

Set Variable [ $Plat ; Value: Get ( SystemPlatform ) ] 

 

If [ $Plat = 1 ] 

#  Mac

Install Plug-In File [ Install Plugin Update if needed::Plugin File Mac ] 

Else If [ $Plat = 3 ] 

#  iOS

Exit Script [] 

Else If [ $Plat = -2 ] 

#  Win

If [ $Arch = "x86_64" ] 

#  Win 64-bit

Install Plug-In File [ Install Plugin Update if needed::Plugin File Win 64bit ] 

Else

#  Win 32-bit

Install Plug-In File [ Install Plugin Update if needed::Plugin File Win 32bit ] 

End If

Else

#  something new or old?

Exit Script [] 

End If

 

Set Variable [ $LastError ; Value: Get(LastError) ] 

If [ $LastError = 0 ] 

If [ MBS("VersionAutoUpdate") = Install Plugin Update if needed::Version Number ] 

Show Custom Dialog [ "Success" ; "Installed MBS Plugin: " & MBS("Version") ] 

Else

Show Custom Dialog [ "Success" ; "Installed MBS Plugin: " & Install Plugin Update if needed::Version Display & ¶ &  "Please restart …" ] 

End If

Else

Show Custom Dialog [ "Failed" ; "Failed to install plugin due to error " & $LastError ] 

End If

 

What do you think? Something missing? The script will be in an example database with next plugin beta version (or email us).

Claris FileMaker Plugin
08 12 15 - 21:13