Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Opening the contents of a container

Featured Replies

  • Newbies

I am a new user of Filemaker (with some previous Java experience) trying to create a searchable project database for a contract furniture dealer. One of the features I feel would be very valuable is the ability to append any type of file (though most likely .pdf or .doc) to the project, and have the end user be able to open the file in Adobe Reader/Word/etc. simply by clicking on a button somewhere. I'm trying to use the Open URL script to accomplish this, and while I can get my script to open a file I specify in the script (such as "C:/Users/me/Documents/test.doc"), I'm having trouble formatting my script to open this file (ie, database location/database name/table name/container name/file name). The pertinent information is structured like so:

Filemaker File is named SampleDatabase3.fmp12
FileMaker File is contained in F:\Sales & Marketing\Neocon 2015\Digital database test

Quote::Quote File - Container (External: Open Storage: Relative to: [database location]/SampleDatabase3
Quote::Quote File Path - Text

 

And the script I currently have is set up like so:

#Opens the attached file in whatever default program is available.
Set Field [Quote::Quote File Path; 
     Let (  [intermediateXtractionString = RightValues(GetAsText(Quote::Quote File); 1); 
  xtractionString = Right(intermediateXtractionString; Length(intermediateXtractionString)-5)]  ; 

"file://F:/Sales & Marketing/Neocon 2015/Digital database test/Sample Database3/" &  xtractionString

) ]
Open URL [No Dialog; Quote::Quote File Path]

The idea is that treating a container as a text field (either by using GetAsText() or simply passing it into a function that expects a text parameter) displays this:

remote:test.doc
FILE:Quote/Quote Field/test.doc

Thus, the Let statement gets the last line (minus the "FILE:" characters) and appends it to what (should be) a valid file path. After I run this script, Quote::Quote Field Path contains "file://F:/Sales & Marketing/Neocon 2015/Digital database test/Sample Database3/Quote/Quote File/Outlook Export Test.CSV", and the Open URL statement does nothing - nothing opens, no error messages, nothing at all, despite the fact that manually copy-pasting this URL into Firefox opens the file. Should I be using Send Event instead of Open URL? Is my syntax wrong? Or is there something I'm not seeing?

Edited by CoryHolden

How about the "export field contents" script step with the "automatically open" toggle on?

  • Author
  • Newbies

How about the "export field contents" script step with the "automatically open" toggle on?

That works beautifully. Will this work regardless of the settings of the container, or does it have to be stored externally?

 

Edit, for those curious about my code;

Set Variable [$extension;
Value: Let (  [intermediateXtractionString = LeftValues(GetAsText(Quote::Quote File); 1); 
  xtractionString = Right(intermediateXtractionString; Length(intermediateXtractionString)-7)]  ; 

Right(xtractionString; Length(xtractionString)-Position ( xtractionString ; "." ; 1 ; 1 )+1)

)]
Set Variable [$extension; Value: "Output" & $extension]
Export Field Contents [Quote::Quote File; "$extension"; Automatically open]

It could stand to be cleaned (I certainly don't need two Set Variable statements), and if I wanted to, I could probably pass in the specific field I want with GetParameter() so I could use this in multiple layouts, but it's functional and it does exactly what I want it to do. Best of all, because all of the files are named "Output", Filemaker overwrites them when it exports them, so you're not saving the entire database to one place (at most, you'll have one file of every extension in whatever location you specify. If you're trying to use this and you want to save a copy of everything, you can use "xtractionString" instead to get the full file name.

Edited by CoryHolden
added code

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.