Avatar of rvfowler2
rvfowler2
Flag for United States of America asked on

FM - Continued Problems with Scripting an Import

In FM, you can't seem to import using the normal file path.  FM helps says the following on scripting an import, however it does not seem to work.  I once got it to work, but now after repeated tries have to admit I forgot how I did it.  From the help below, I tried various iterations of the following directly below, but the import did not work from the script (though does work from my PC).  Any suggestions?

/Library/FileMaker Server/Data/Documents/unitaddy.txt
-------------------------------
 When using the Import Records script step or Export Records script step in a FileMaker Server scheduled script, keep the following in mind:

  •  Any specified file must be in the FileMaker Server Documents folder, the temporary folder, or a child folder of either the FileMaker Server Documents folder or the temporary folder. For example, the following are all valid paths for file.csv:

<Documents>/file.csv
<Temporary Path>/file.csv
<Documents>/Folder1/file.csv
<Temporary Path>/Folder1/Folder2/Folder3/Folder4/file.csv
  •  Any path specified that isn’t a complete path to the file (for example, anything other than
/Library/FileMaker Server/Data/Documents/<0 or more directories>/<filename> ) is evaluated as being relative to the temporary path.

  •  Any paths that include “..” are considered invalid.

  •  For FileMaker Pro, if an absolute path is not specified in a script that will be executed from FileMaker Pro, the path is assumed to be relative to the location of the database file from which the script was run. For example, if a script containing the Export Records script step is run with the pathname file:/export.tab, and the file running the script is /MyFiles/Library/Books.fp7, the exported file will be created as /MyFiles/Library/export.tab.

FileMaker Pro

Avatar of undefined
Last Comment
rvfowler2

8/22/2022 - Mon
North2Alaska

Are you doing this script to be used on a server?  Or is this only a local database?
rvfowler2

ASKER
Yes, a scheduled script on the server.
North2Alaska

Sorry, I'm not up to speed on the server side.  :-(
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Robert Jackson

Hope this helps?

FileMaker Server can only import from and Export to the following locations:

When using the Import Records script step or Export Records script step in a FileMaker Server scheduled script, keep the following in mind:
Any specified file must be in the Documents folder, the temporary folder, or a child folder of either the Documents folder or the temporary folder. For example, the following are all valid paths for file.csv:

<Documents>/file.csv
<Temporary Path>/file.csv
<Documents>/Folder1/file.csv
<Temporary Path>/Folder1/Folder2/Folder3/Folder4/file.csv

Any path specified that isn’t a complete path to the file (for example, anything other than/Library/FileMaker Server/Data/Documents/<0 or more directories>/<filename> ) is evaluated as being relative to the temporary path.
Any paths that include “..” are considered invalid.
Here is an example script that shows how to construct a "Documents" path when exporting using a variable:

*Set Variable [$filepath; "filewin:" & Get(DocumentsPath) & "Export.csv"]
** Export Records [No dialog; "$filepath"]

*Set Variable Options:
Name: $filePath
Value: Use one of the following formulas
Mac:  Get(DocumentsPath) & "Export.csv"
Windows: "filewin:" & Get(DocumentsPath) & "Export.csv"
Repetition: 1
rvfowler2

ASKER
Good try, but it didn't work, maybe because I wanted to export rather than import.  When I put $Filepath in the import script step for the file, no fields came up to match.  I then tried putting in "filewin:" & Get(DocumentsPath) & "Export.csv" but the import script step rejected that as a valid file name.  I once again tried the following file path to be sure I tested it correctly and it failed; the data did not import from a server scheduled script, though the text file is in the documents folder.  However, the data did import if I ran the script manually from my PC. (see below)

I've even opened up FM Pro on the server and then browsed to the txt file in the documents folder from there, but that doesn't even work.

filewin://Sbsunited/FileMaker/FileMaker Server/Data/Documents/unitAddy.txt
Robert Jackson

Pity about that!  Thought that would have done the trick.

NOTE: Import/Export is not compatible with Instant Web Publishing.

To see whether a script step is compatible with FileMaker Server:

In FileMaker Pro, choose Scripts menu > Manage Scripts.
In the Manage Scripts dialog box, double-click a script name or create a script.
In the Edit Script window, select 'Server' from the Show Compatibility list.
Script steps that are not supported from a FileMaker Server schedule appear dimmed. The text (NOT COMPATIBLE) appears next to the script step in the Edit Script dialog box.

Use the Get ( DocumentsPathListing ) function with the Import Records and Export Records script steps to determine if a file exists before using the Open File script step to open the file, and to ensure that multiple scripts can safely read and write to the same FileMaker Pro Database.

Supporting import/export formats:
Importing/exporting directly to and from another FileMaker Pro file is not supported via a FileMaker Server scheduled script. The supported import/export formats include:

Comma- Separated Text format (csv or .txt)
FileMaker Pro HTML Table format (.htm) Export only
Merge format (.mer)
Microsoft Excel format (.xls or .xlsx)
Tab-Separated Text format (.tab or .txt)
XML format (.xml)
dBase files (.dbf)
In addition, importing/exporting to a ODBC data source is supported.

Important: In order to import/export to another FileMaker Pro file via a FileMaker Server scheduled script, the script would need to export the records from the FileMaker Pro file to one of the below valid paths and then import the records from this file into the other FileMaker Pro file.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Robert Jackson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rvfowler2

ASKER
Thanks, but that just provided me with the same filepath as if I browsed through the C drive, which I've already done.  I've tried all of the following with no luck:

filewin:/Library/FileMaker Server/Data/Documents/unitAddy.txt
filewin:/C:/Program Files/FileMaker/FileMaker Server/Data/Documents/unitAddy.txt
file:/c:/Program Files/FileMaker/FileMaker Server/Data/Documents/unitAddy.txt
filewin://Sbsunited/FileMaker/FileMaker Server/Data/Documents/unitAddy.txt

I emailed Jason of FM Northeast (though he has no obligation to respond) to see if FM really does import from a scheduled server script.  Beginning to have my doubts.  
Robert Jackson

What version of FM Server are you using?  As in 8, 9 , 10, 11 ?
Robert Jackson

The filepath file just served to eliminate the possibility that it was the filepath that was the problem.  Now we can move on.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Robert Jackson

The event log will tell you exactly what FM error was raised. You can look up the error description in the FM help.  It should point us in the right direction?
Robert Jackson

Did you check your script steps for server?
script2.png
SOLUTION
rvfowler2

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rvfowler2

ASKER
In a previous post above, I had the same path (though different txt file) as directly above, except that the C drive was indicated by a small "c", but I don't see how that made a difference.  Ah well, working now.  Thanks for hanging in there with me.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.