Well I guess that probably one of the two steps don't work for whatever reason. To find out which one it is make a script that checks the results, such as:
set variable $$NAME ( get(FileName) )
show dialog $$NAME
set window Title ($$NAME)
set window Title ("test")
Please notice, that "get(fileName)" gets the name of the current FileMaker file, not the imported file.
To set the name to the imported file is a little more tricky and depends on what kind of file it is (FMP, Excel?):
1. If it is a FMP file you could try to activate the window of the import file and get the filename before closing it.
2. If it is an Excel file you could just drag it to a container field in order to import it. Then you can read the filename with get(ContainerAttributes), export the field content to let's say the temporary FMP path and reimport it again with a script step that is using the calculated path.
works fine here
- I've set the window title to 'demo' since by default it's the name of the file
- I created a script that uses 'get(filename)' as a calc' - works
Could You try that in a new file? Could be that there are script triggers, etc...
here's my test-script
Fenstertitel setzen [ Aktuelles Fenster ; Neuer Titel: Hole(DateiName) ]
// Fenstertitel setzen [ Aktuelles Fenster ; Neuer Titel: "demo" ]
the second line is deactivated, needed that just to set another windowtitle
'Fenstertitel setzen': Set Window Title (current window; New Title...)
(copied the script-text using MBS Plugin)
This what I did, but it doesn't work. The name of the solution itself is showing, not the name of the file that was imported.
The imported file is an FMP file. How do I activate the imported file's window? I can't find a script step for that.
Get(FileName) shows the name of the current file. If You have 'Your_file' _and_ a second one (the import-file), the function has to be activated from the second file... means the script has to be in the import-file
You mean like within a field or something like that?
I created a field with the Get(FileName) calculation and called that field in the open Script step. Still, the window shows the name of the solution itself, not the imported file.
No, the script that sets the window title has to be started from the import_file
I made you an example file that does all the work for you. Try it: Just drag your Import file to the Container Field.
In order to make it work in your solution you have to:
a.) copy the script
b.) then copy the Field to your solution table
c.) copy the Field on to your Layout (Incl. the script trigger)
SetWindowName.fmp12.zip 135.4 K
Thanks so much, I will have a look.
The "Import File" (or drag) to container gets you the filename (with various functions). Then if you need to "import", you can set this filename to a variable, export the container contents and re-import. If the stored filename (in the variable) needs to appear in the records newly imported, then you can use a Replace() to that found set to the proper field.
NOTE: an import gets you a found set automatically, however with this caveat: verifty that the count of all records has indeed increased, before performing a Replace. You can use variables to store previous total count, store the found set after import and compare that the change is previous count + import count = new count. You do not wish to overwrite any previous records, just the newly imported ones.
I was not able to test the sample provided by cheesus so this may be in there. I mostly wanted it in a searchable reply on this forum.