Jump to content

"Insert from URL" to insert PDF on FM Server


Recommended Posts

  • Newbies

I am running a script on server (perform script on server) which successfully exports data to a PDF on the server ("Save Records As PDF"). Later in the script, I am trying to insert this PDF file into a container, using the "Insert from URL" script step.

No matter what I do, I am always getting back errors. 

FM server is running on a Mac server.

I have tried all combinations of different parameters for "Insert from URL", with various formats for the URL (starting with “file”, “filemac”, followed by “:/”, “://”, “:///”).
Depending of the combination, I am getting either one of these errors back:

5 - Command is invalid (for example, a Set Field script step does not have a calculation specified)
1630 - URL format is incorrect
1631 - Connection failed

Help how to resolve this and successfully insert the PDF into the container field would be appreciated. Thank you.

 

Link to post
Share on other sites

See if something like this works:

"file://" & Get ( DocumentsPath ) & "fileName.pdf"

 

Link to post
Share on other sites
  • Newbies
45 minutes ago, Josh Ormond said:

See if something like this works:


"file://" & Get ( DocumentsPath ) & "fileName.pdf"

 

Thank you Josh.

I already have a path generated where the file gets exported to in "Save Records As PDF", which works perfectly. That path begins with "filemac:/". Like I mentioned, I tried all combinations between "file:", "filemac:" and ":/", "://", and ":///". 

Link to post
Share on other sites

To insert a file from URL, you need a URL using the file protocol, not a Filemaker path. In macOS such URL will typically look like:

"file:///Users/YourUserName/Documents/YourFile.pdf"

which is different from what you would get from a calculation using 

"file://" & Get ( DocumentsPath ) & "YourFile.pdf"

 

  • Like 1
Link to post
Share on other sites
11 hours ago, jschudel said:

I already have a path generated where the file gets exported to in "Save Records As PDF", which works perfectly. That path begins with "filemac:/". Like I mentioned, I tried all combinations between "file:", "filemac:" and ":/", "://", and ":///". 

If you use a path like @comment pointed out, it will work. I typically use a custom function for this process that handles the path for me, and I neglected to show the adjustment to the path. But it does work with that path he showed.

 

"file:///" & 

Let ( 

[

path = Get ( DocumentsPath ) ; 
transformPath = Substitute ( Get ( DocumentsPath ) ; "/" ; "¶" ) ; 
listCount = ValueCount ( transformPath ) ; 
adjustedList = MiddleValues ( transformPath ; 3 ; listCount - 2 )  ; 
newPath = Substitute ( adjustedList ; "¶" ; "/" ) ; 

result = newPath

] ; 

result

) & 


"fileName.pdf"

 

Link to post
Share on other sites

That's a long calculation - I would reduce it to:

"file:///" 
& 
Replace ( Get ( DocumentsPath ) ; 1 ; Position ( Get ( DocumentsPath ) ; "/" ; 1 ; 2 ) ; "" )
&
"fileName.pdf"

Still, it needs to be pointed out that this is specific to the Mac platform.

 

Link to post
Share on other sites
  • Newbies

@Josh & @comment. Thank you guys! Worked like a charm now that I finally understood that the URL has to have a different format! 

Link to post
Share on other sites

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.