August 28, 20232 yr 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
August 28, 20232 yr 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 August 28, 20232 yr by comment
August 28, 20232 yr 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
August 28, 20232 yr 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?
August 29, 20232 yr 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.
August 29, 20232 yr 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.
August 29, 20232 yr 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
August 29, 20232 yr 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 August 29, 20232 yr by comment
August 29, 20232 yr 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