June 3, 20205 yr 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.
June 3, 20205 yr See if something like this works: "file://" & Get ( DocumentsPath ) & "fileName.pdf"
June 3, 20205 yr Author 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 ":///".
June 3, 20205 yr 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"
June 3, 20205 yr 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"
June 3, 20205 yr 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.
June 4, 20205 yr Author @Josh & @comment. Thank you guys! Worked like a charm now that I finally understood that the URL has to have a different format!
Create an account or sign in to comment