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

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

Recommended Posts

Posted

My client wants his users to be able to choose a hard drive location as their preferred location for outputting PDFs. Because there will be many individual computers, some Windows, some Macs, some with access to a network, some not, I can't really hardwire the code (or assume I can't).

They're doing this on a budget, so don't want to fork over additional fees for a plug-in. I've looked at ScriptMaster but don't have enough coding chops to sort out what's relevant, what's not and pierce through its twists and turns.

What would you do in this situation? Am I missing something that's obvious. I'm using FMP10 Advanced to develop this.

Appreciated.

Posted

"My client wants his users to be able to choose a hard drive location as their preferred location for outputting PDFs."

As opposed to what? Their desktop?

You could have a preferred path for pdfs stored in each users record in your Users table. Publish it to a global (field or var) in an Open script, and use it as part of the path (you still need to add filename) in your create PDF script.

Posted

If you want to actually "ask" the users where they want all their PDFs to go, then things become tricky. You could do that using plain FileMaker. But I think the only way to get a folder path into FileMaker would be to Insert a file into a container field [x] as reference only. You could then extract the absolute path from that, using GetAsText ( container ), get the last line, using GetValue().

Another method, which would likely be a better dialog (as it would not say "Insert File") would be to use AppleScript on a Mac, or (free) MooPlug plug-in on Windows. AppleScript has an explicit "choose folder" command, which is what you want. But it returns an AppleScript "alias," so you'd need to coerce that to text ("as text"), and set into a FileMaker field. Then add the FileMaker prefix when you did your Save As PDF. MooPlug also has a choose folder command, which, since it is a plug-in, could write directly to a FileMaker field. It would also need the FileMaker prefix added before you could use it, as it returns an OS syntax path (all external tools will).

Since the path is going to be set into a FileMaker field, for each user, it makes sense to do that in a Users table, with a record for Account who could log in. Read it from there.

Posted

If you want to actually "ask" the users where they want all their PDFs to go, then things become tricky. You could do that using plain FileMaker. But I think the only way to get a folder path into FileMaker would be to Insert a file into a container field [x] as reference only. You could then extract the absolute path from that, using GetAsText ( container ), get the last line, using GetValue().

Yes I do want to ask the users where they want their PDFs to go and I want to store it in a variable. My client needs to produce a quantity of PDFs, each one personalized. Therefore in the generation of the PDFs I'll be looping. I want to supply FMP with both the file name and the absolute path via variables. (Should have explained this before.)

I'm almost there but am having trouble with the GetAsText(container) call. Instead of ending up with the path the user chose, GetAsText(container) returns the path to the FMP file itself, and then appends the PDF file name — strange.

Here's the whole thing, step by step.

1. Set the container to empty.

2. Save Records as PDF [Restore; No dialog; "text.pdf"; Current record]

This places a tiny PDF file in the same directory as the FMP10 file – ExportToContainer.fp7

3. Insert File [Reference; ExportToLocation::container; "txt.pdf"]

Insert the PDF into the container field.

4. Export Field Contents [ExportToLocation::container]

The target field is identified but the location to put it is not. Therefore a dialogue opens up allowing the end user to choose. For purposes of testing I'm choosing the "New PDFs" folder on the desktop.

5. Set Variable [$Path; Value:GetAsText (ExportToLocation::container)]

This is the step that's probably in error. It picks up the FMP10 file's location and then appends the file name.

6. Set Variable [$Path; Value:GetValue ($Path; 2]

Returns the second of the two paths.

7. Export Field Contents ["txt.pdf"]

Remove the txt.pdf file from the original location, next to the FMP10 file.

I've appended my test file.

ExportToLocation.fp7.zip

Posted

1. Set the container to empty.

2. Save Records as PDF [Restore; No dialog; "text.pdf"; Current record]

This places a tiny PDF file in the same directory as the FMP10 file – ExportToContainer.fp7

3. Insert File [Reference; ExportToLocation::container; "txt.pdf"]

Insert the PDF into the container field.

4. Export Field Contents [ExportToLocation::container]

The target field is identified but the location to put it is not. Therefore a dialogue opens up allowing the end user to choose. For purposes of testing I'm choosing the "New PDFs" folder on the desktop.

5. Set Variable [$Path; Value:GetAsText (ExportToLocation::container)]

This is the step that's probably in error. It picks up the FMP10 file's location and then appends the file name.

- Yes, the value is still from step 3. I don't think you can grab the EXPORT location.

6. Set Variable [$Path; Value:GetValue ($Path; 2]

Returns the second of the two paths.

7. Export Field Contents ["txt.pdf"]

Remove the txt.pdf file from the original location, next to the FMP10 file.

-----

I got it to 'work', but it relies on having a "dummy" file already in that folder. I modified your script as follows:

1. Set Field [ETL::container; ""]

Set field [ETL::text1; ""]

2. Insert File [Reference; ETL::container]

- This is asking for a file in the ultimate destination directory.

3. Set Variable [$Path; Value:GetValue ($Path; 2]

Returns the second of the two paths.

4. Set Field [ETL::text1; $Path]

---------

This just gets you the destination folder and filename. The next step would be to remove the filename from the path (I'm not smart enough to be able to custom function up a "Whatever is right of the last forward slash") and then you'd have the folder path.

It looks like without plugins of some sort you can't pull the export path by exporting, you have to get an export path by importing something that is already in the destination folder.

Keep in mind I consider myself an intermediate user at best, so don't invest too heavily in my post. I'm here to learn :(

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