I have a simple script that goes to a table, performs a find & exports a small set of records. It's an extremely simple script, but I am having a nightmare getting the export to my Server docs folder when running this script on my local machine via the PSOS script step.
I get no error messsage when I run the script but the file just doesnt export to my server docs and its driving me crazy as it should be so simple, I'm beginning to think this is a permissions issue.
I have tried a million different file paths such as
"filewin:" & Get(DocumentsPath) & "test.csv"
"filewin:/" & Get(DocumentsPath) & "test.csv"
"filewin://" & Get(DocumentsPath) & "test.csv"
"file:" & Get(DocumentsPath) & "test.csv"
So on and so forth, most return no error, yet the file is no where to be found? I'm 99% sure its nothing to do with the filepaths as I've never had this problem before.
You don't need "filewin" at the beginning. If you are using the built in Filemaker functions first set a variable $file_path = Get ( DocumentsPath ) & "you_file_name.csv". Then the "Export Records" script step with the following options:
Specify Output File -
Output file path list = $file_path
File type = CSV
This will export a csv of your records to the documents folder, unless, the user account FileMaker Server is using does not have file permissions. When you set up the server, if you changed the default account that FileMaker Server uses - you'll need to add permissions to your folder and parent folders.
You can check for errors by using the "Exit Script" script step. Set the text result to = Get ( LastError ). Then use "Set Variable" = Get ( ScriptResult ) to pass this error into the script that called the PSOS script. Place the "Exit Script" script step just after the export records script step to find out why it's not creating the file.
If you are using plugins to export the records like BaseElements you'll need to convert the file path that FileMaker gives you to one that BE can use. Essentially Substitute ( $file_path ; "/C:" ; "" )
Hope this helps.