Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5462 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

I came across this post on the FM help forums: http://forum-en.filemaker.com/fm/board/message?board.id=FM-en-4&message.id=28046

The poster (ralvy) included the following quote from the FM documentation:

"If you import records from a closed file or an open file that is not displaying any windows, FileMaker Pro imports all the records, regardless of any found set."

Can anybody confirm that this works as described? I'm specifically talking about the part about an "open file that is not displaying any windows." This is the behavior I want, but it doesn't seem to work. I tested by doing the following:

1. Open my destination file

2. Open the source file

3. Go to a layout in the source file for the table I want to import, and Omit All Records (for the purposes of this test)

4. Click on 'Hide Window' to make it hidden

5.In the destination file, do an Import Records

Now... According to the quote above, I would expect all the records to be imported, even though the found set was empty. However, this does not work. No records are imported.

Any thoughts?

ps. I know that importing from the closed file would indeed import all records, but I'm interested in importing from an open file. If this worked as described, it should allow me to use the "Open File" script step with the "Open hidden" option, and then import all records without needing to enter a password (assuming a matching user/pass exists in the source file).

[EDIT] I guess I forgot to tick the box to include my system details. I'm using FMPA10 on both OS X and Windows SP SP3. Same result on both.

Edited by Guest
Posted (edited)

Now... According to the quote above, I would expect all the records to be imported, even though the found set was empty. However, this does not work. No records are imported.

Isn't it becasue the scripting you call in the sourcefile doesn't provide an extra window to continue the scripting from:

http://fmhelp.filemaker.com/fmphelp_10/en/html/scripts_ref2.37.4.html

Where it's said:

Note Closing the last window of a file closes the file and halts execution of the current script.

If you teminate you subscript with a parameter will you notice that it never gets it, when controlling in the calling script.

In my test did the subscript in the source file look like this:


New Window [ Name: "dummy" ]

Go to Layout [ “Layout #2” (dummy) ]

Select Window [ Name: "file1"; Current file ]

Omit Multiple Records [ 250 ] [ No dialog ]

Close Window [ Current Window ] 

Exit Script [ Result: "done" ]





...and the calling script looked like this:





Perform Script [ “Sub script” from file: “file1” ] 

If [ Get ( ScriptResult ) = "done" ]

     Import Records [ Source: “file:file1.fp7”; 

                       Target: “file2”; Method: Add; Character Set: “Mac Roman”; 

                       Field Mapping: Source field 1 import to file2::field1

                       Source field 2 import to file2::field2 Source field 3 import to file2::field3 Source field 4 import to file2::field4 ]

     Close Window [ Name: "dummy" ]

     Show Custom Dialog [ Message: "An import should have happened here"; Buttons: “OK” ] 

End If

Whether you enable the two first lines in the subscript makes the entire difference.... and must be the issue which you had a hard time interpreting???

--sd

Edited by Guest
Posted

Hi Søren,

Thanks for your reply. Your technique works, though it is not exactly what I am trying to do. I do not want to run any scripts/subscripts in the source file. Do you know any way of doing that?

Posted

I believe "an open file that is not displaying any windows" refers to a file that is "opened" by reference. Such file displays in parentheses in the Show Window menu.

Posted

Do you here ignore the found set of the source file, which isn't related in any way except the present mapping?

But if it's launched by opening the present file could it be in the graph and by it be given it's own layout where any kind of found sets could be established. The import dialog should then NOT point at another file as expected but instead at it self, and use the relayed table from the graph as source.

If you build it this way, won't you be prompted for password...

--sd

OpenOnlyReciever.zip

Posted (edited)

OK, I now pretty much have this working the way I want it. Thanks to both Soren and Comment for pointing me in the right direction.

So, I'm now able to import all records from a closed file, without the need for a 'Show All Records in all Tables' script in the source file, and without prompting for a user/pass at each Import Records script step.

The key to making it work was to simply have one Table Occurrence of a table from the linked (source) file, then creating a layout based on that table occurrence. The layout does not even need to have any fields on it. Once the layout is viewed (by a user or by script) this opens a 'link' to the source file. At this point, you can see the window name of the source file listed under the Show Window menu, within parentheses. This is what Comment referred to. Once this link has been established, it will remain open and you can perform any operations as if that file is open, but any found sets within that file are ignored (as if it were closed). This now makes it much simpler to script a full data migration from one db to another without too much hassle or user interaction.

Sample files (modified from Soren's sample) attached.

[EDIT] The user/pass for the attached files is admin/123

ImportRecordsFromClosedFile.zip

Edited by Guest

This topic is 5462 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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