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.
Juggernaut

Getting field contents with a variable

Featured Replies

I have a document management layout that manages several different versions of a document in the record.

I don't want the field with the doc name to be a button as i need to access the field for other purposes.

So I want to use a single script for multiple buttons opening the file in one particular field using a Script Parameter for the field name.

So I set a variable $Field as Get (Script Parameter).

Now i want the script to tell it to get the content of the relevant field.

(Ignoring the full path on my computer)  I tried

Set variable [$File;Doc::$Field]  but Filemaker says it can't find that field and rejects the setting.

How do i achieve that result?

Thanks for your help

Solved by mdfOffman

Go to solution

What exactly is being passed as the script parameter? Is it:

  • the name of the field as text (e.g."SomeField"); or
  • the full name of the field as text (e.g. "SomeTable::SomeField"); or
  • a reference to the field (e.g. SomeTable::SomeField)?

 

Edited by comment

  • Author

I think I must answer this with a question:  Which should it be?  Which is best?

Whichever way achieves the desired result most efficiently,

I need to have a routine that:

1.   has a parameter carried to a variable

2.   that then captures the file name stored in the target field.

I feel it should be simple but I'm not getting there 😞

Thanks

 

23 minutes ago, mdfOffman said:

Which should it be?  Which is best?

It depends on what you intend to do with the field. You say you want "to get the content of the relevant field". What exactly does that mean? What type of fields are we talking about? Are they container fields - and if so, do they store the files or only a reference?

 

  • Author

OH, I'm sorry.  I didn't make that clear.

The field i want to access is simple text with the name of the file.  

The button with the relevant script is an "Open URL" button starting with "file://" that opens the local instance of a Dropbox-synced file.  So the file path ends with the name of the file that is stored in the field to be read.

I hope that makes it clear. 

3 hours ago, mdfOffman said:

The field i want to access is simple text with the name of the file.  

If you pass a reference to the field (with no quotes) as the script parameter, then the parameter will contain the text stored in the field (i.e. the filename).

You can then use the Open URL script step to open the file in its native application using a URL calculated along the lines of:

"file://path/to/some/folder/" & Get ( ScriptParameter )

There is no need to set a variable to the contents of the script parameter; the script parameter itself is a type of variable.

---
Side note: If each filename is stored in a separate field, then you cannot (at least not easily) find a document by its filename. Or produce a list of all filenames. Consider storing the filenames in a separate related table.

 

  • Author

So I try to specify the path as either

"file://" & $Path & "/"& Doc::Get(ScriptParameter), or

"file://" & $Path & "/"& Doc::$Field

Either way it says the specified field cannot be found and refuses to accept the specification

It accepts as far as "file://" & $Path & "/" but not when I attempt to add the field name whose contents I am looking for. 

I can use a separate script for each version button but that seems very inefficient.  I want a single script with a parameter

 

I don't see what theDoc:: prefix has to do with anything. If the $Path variable contains the path to the folder, and the field passed as the script parameter contains the filename, then the URL should be calculated as:

"file://" & $Path & "/" & Get ( ScriptParameter )

(this is assuming that $Path does not end with a slash).

---
Here's a general procedure how to solve problems like this: first, get the correct path to the file (for example, insert it into a container field as reference only and observe the path). Then turn on the 'With dialog:' option of the Open URL step. Now you can compare the calculated path to the correct path and make the necessary adjustments.

 

 

Edited by comment

  • Author
  • Solution

Thank you. once again, dear Guru!

I did actually follow your procedure.  I just didn't think of including both the table name and the field name (without brackets) as the parameter.

Works perfectly.  Sorry to be so slow ......  I knew it was easy once you know!

I meant "without quotation marks"

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.