I have found that it may be easiest to export the found set to a temp file and then change layouts and import the file. I find that using XML works well because it includes the field names. Assuming that the field names match then you can have the import match on the field names. If not you can easily line them up and save the script.
Partial script example
Go to Layout [ “Task - Blank” (Task) ]
Set Variable [ $_tsk_fn; Value: Choose(Abs(Get(SystemPlatform)) -1; Get ( TemporaryPath ) & "_tsk.xml"; "filewin:" & Get ( TemporaryPath ) & "_tsk.xml")]
Export Records [ File Name: “$_tsk_fn”; Grammar: "FMPXMLRESULT"; Character Set: “Unicode (UTF-8)”; Field Order: Task::_H_Display..]
Go to Layout [ “TaskImport - Blank” (Task2) ]
Import Records [ XML (from file): $_tsk_fn; Target: “Task”; Method: Add; Character Set: “UTF-8”; Field Mapping: Source field 1 import to Task2::___ID]
[ No dialog; Data contains column names ]
I find that even with a fairly large record set the method is quick. It works in both 11 and 12.
It seems to me that, if that's the approach I have to take, it might be simpler to use a FileMaker file in the root directory of the server and specify just the filename (i.e. the relative path).
But, ideally, I'd like to handle this with out external files of any kind, because it's simpler for the client that way.
You have to use a script variable when specifying the path to the file in the Import script step.
Set Variable [$selfPath; Value:Get(FilePath)]
Import Records ["$selfPath"]
So, just to be clear, on the server, Get(FilePath) would return the value of the path and filename of the solution file from which the script is being run?
I haven't tried this with FMS. I misread your initial post that referenced FMS12.
I did successfully use it with FMPA 11 on a local file.
If this works directly in FMS, then great.
If not, using a script variable and assigning it a calculated value is a solution. You would need to figure out what the file reference needs to looks like and then calculate it based on something else (e.g. Get(FileName)).
Okay, it's easy enought to try. Though I was hoping to get a deffinitve answer because I have to e-mail new builds to the client's network guy (who is a separate company) and then wait for him to upload it and their employees to test it.
1 of 1 people found this helpful
I just tested this connecting remotely with FMP 11 to the original test file hosted on FMS 11.
It worked fine.
when the file is hosted on the server. This works fine for the file path in the Import script step.
When invoked on a locally hosted file Get(FilePath) starts with "file:".