Jump to content

Problems with setting filepath for records export


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

Recommended Posts

Hello

I am trying to write a script which exports a set of records in fp7 format.  the filename is appended by the current date.

 

In the first instance I can't get the filepath to work. 

I can get it to work by just entering a filename into the export files dialog box ie file:filename, but this dumps the file into the Filemaker Pro folder

or I can get it to work by putting the entire filepath.

 

filemac:/Volume/Users/admin/desktop/filemame

 

the problem is this would only work on my computer and this is a shared database - is there a generic filepath I can use which could solve this

I have tried various combinations

For example

file:/desktop/filename

 

But keep getting the same message ie File could not be created on this disc.....

 

Does anyone know what I am doing wrong

 

Many thanks

Link to comment
Share on other sites

Ok thanks for that

I have got that working using get (desktopPath)

the only problem now is the actual filename 

What I want is a filename appended with the date the file was produced

So I have set up a calculation field which holds the filename and the date (using get (currentdate)

this works OK and I can see the correct filename in the field I have set up a variable which uses this field so the filepath looks like this

$Filepath/$filename

If I type text in as the filename it works but it does not seem to want to accept a variable - it either throws it out or sets the actual filename as $filename

Anyone know what I could be doing wrong

Many thanks for reading

Link to comment
Share on other sites

it does not seem to want to accept a variable - it either throws it out or sets the actual filename as $filename
 
What exactly does "throws it out" mean"? I am also not clear on the "or" part: computers are not capricious - you must have changed something on your part to get a different result. Such as removing the $ prefix from the variable name.
 
Properly, your entry in the Export Records step should look like this:
filemac:$filepath/$fileName

I don't think the absence of the 'filemac:' prefix should make a difference, but it's worth checking.

 

 

The other thing is that the result of Get ( CurrentDate ) is very likely (depending on your date format in use) to contain forward slashes - and you will get an error message in such case, because a file name of "10/17/2013" will try to create a file named "2013" in a folder named "17" in a folder named "10" in the directory specified by $filepath.

 

Link to comment
Share on other sites

When saving a file and appending the current date using Get(CurrentDate) I wrap that function in the Sustitute function and replace the slashes with underscores. Today would be 10_17_2013. This avoids escaping the slashes and it's easy to understand.

Link to comment
Share on other sites

Hi all

That has cracked it

Putting filemac: and using the substitute function to change the date seemed to do the trick

So final script looks like this

 

Set variable [$filename; Value:Substitute (Table::Filename;"/";"-"0)]

Set Variable [$Filepath; Value:Get (DesktopPath)]

Export records ["$filename";Automatically open; Unicode UTF-16)]

 

With a filepath of        Filemac:$Filepath/$Filename

 

The filename field holds the name of the file and the current date

Link to comment
Share on other sites

  • 2 years later...

in everytime, if I want to choose where I will export ,

which way  should I use in Export records with script ?

I want to see " Export records to file" with  "Excel workbooks(*.xlsx)" as record type. Than  I will give  name of  "filename" in everytime.

Edited by Mustafa55
Link to comment
Share on other sites

Just use a plain Export Records without anything else - unfortunately, it will always default to Tab Separated, but it's in the drop down to change to Excel.

Also might be better to start a new thread for questions that were last answered 18 months ago...

Link to comment
Share on other sites

This topic is 2991 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.