Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

Solved by Johnny777

Go to solution
  • Author

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

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.

 

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.

IMHO, it would be better to calculate a result of "20131017" or similar. This way the files would be sorted correctly by name alone.

I'm missing something about the sorting. Do you mean how they would be sorted in a finder window?

Rick.

Yes.

  • Author
  • Solution

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

  • 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

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...

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.