milky Posted September 21 Share Posted September 21 Hi All, I am attempting to write a script to automate the process of printing 600 chart images, to separate PDF's. Everything works correctly if I carry it out manually as follows: New Window using Layout, Show All Records, Constrain Found Set, Sort Records, Go to First Record, Preview, Save as PDF, the correct Folder on my One Drive appears, I use options to specify 1 page and click on a current file to overwrite. I then created a script as per the attached image, named Chart Layout Open. This works correctly. When I am on that Layout I select another button that runs the script as per the attached image, named Chart PDFs and I receive the following error message as per the image attached, named error message. I have also tried not using One Drive in case One Drive is the problem and saved to C:\Temp\ which returns the same error message with the file path changed to C:\Temp\ Any help solving this problem would be greatly appreciated. Milky. Link to comment Share on other sites More sharing options...
comment Posted September 21 Share Posted September 21 (edited) You need a Filemaker path, not a Windows path - see: https://help.claris.com/en/pro-help/content/creating-file-paths.html See also: https://help.claris.com/en/pro-help/content/convert-to-filemaker-path.html --- A few other points: A backslash before a quotation mark escapes the quotation mark. Showing all records and then constraining the found set is an inefficient way to accomplish something that can be done simply by performing a find. Do not use global variables (prefixed by $$) where script variables (prefixed by $) will do. Edited September 21 by comment Link to comment Share on other sites More sharing options...
milky Posted September 23 Author Share Posted September 23 Thanks Comment, I altered the path to a FileMaker path as per the image below, but I am still getting an error message. Link to comment Share on other sites More sharing options...
comment Posted September 23 Share Posted September 23 I believe you are missing a / character at the end of "... 2024/Charts". And you should not be quoting the variable name. There are others factors that could be causing the failure, which we cannot see. I presume those XXXX parts are hiding sensitive data, but it could be that the path to the Charts folder is incorrect. And we don't see what's in the Nickname field. I also wonder what type of field is the Nickname field and why do you think it needs to be converted to Text. -- P.S. Please try to post your code as code, not as pictures. Link to comment Share on other sites More sharing options...
comment Posted September 23 Share Posted September 23 BTW, here's an idea you could use in your attempts: https://fmforums.com/topic/62953-container-to-accept-file-path/?do=findComment&comment=298657 Link to comment Share on other sites More sharing options...
milky Posted September 23 Author Share Posted September 23 Thanks Comment, I added the / and deleted the quotes and received the error message below (persons name altered to Fred Flint - the actual file is present in the Charts Folder and works when I carry out the task manually). I have included the code as it is written with actual folder names etc: #Ensure the field Value is treated at text Set Variable [$$ChartFileName; Value: (GetasText(Players::id_fk_Player Nickname); "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" ) & ".pdf"] #Set the full file path Set Variable [$$ChartPath; Value: "filewin:/C:/Users/milta/OneDrive/Toowong - Personal/Toowong Website - 2024/Charts/" & $$ChartFileName] #Save the current record as a PDF Save Records as PDF [Restore; With dialog off; “$$ChartPath”; Current Record; Create Folders:Off] Link to comment Share on other sites More sharing options...
milky Posted September 27 Author Share Posted September 27 Hi Comment, I altered my script as follows: # Set the correct path: Set Variable [$ChartPath; Value: "filewin:/c:/Users/milta/OneDrive/Toowong - Personal/Toowong Website - 2024/Charts/" & Players::FirstAndLastPDF] FirstAndLastPDF concatenates the players First name, then a space, then the Last name, then a period, then the text pdf. e.g Fred Flintstone.pdf # Print Setup for Landscape: Print Setup [Restore; With dialog:Off;] This is set to: Microsoft Print to PDF, A4 size, Landscape. #Save records as PDF: Save Records as PDF [Restore; With dialog: Off; "$ChartPath; Current record; Create Folders: Off] In the specify options, Save: Current record and Options: Specific pages 1 through 1 is selected. I still get the same error message. I have tried the same script with the path as filewin:/c:/Temp with no luck. Any assistance would be greatly appreciated. Link to comment Share on other sites More sharing options...
comment Posted September 27 Share Posted September 27 I am afraid I don't know how to help you further. It's not possible for me to reproduce the error from your description, so ... I repeat my suggestion to compare the result of your path calculation with the actual path you get from inserting a file into a container field, character by character. You may also see what you get with a path calculated as = Get ( TemporaryPath ) & Players::FirstAndLastPDF If this produces an error, then there is a problem with the calculated filename (at least). Link to comment Share on other sites More sharing options...
milky Posted September 28 Author Share Posted September 28 I just tried utilising Specify Output File. I clicked the Add File button and then selected the path to the folder I want to save the pdf's in. This added in the Output File Path List: file:Toowong Website - 2024/Charts/untitled.pdf. This worked and saved the current file in the correct folder as Untitled. I then tried to use Players::FirstAndLastPDF instead of Untitled and this got the same error message. So now my question is how do I name the filepath so that when I carry out a loop of all records, it names the file by using the Players name and it doesn't just keep overwriting the Untilted.pdf file? (I also tried aaaa.pdf and this worked, so it is the field reference that is causing the issue. Link to comment Share on other sites More sharing options...
comment Posted September 28 Share Posted September 28 1 hour ago, milky said: then tried to use Players::FirstAndLastPDF instead of Untitled It's not clear how exactly you tried this. And we still don't know what exactly is in the Players::FirstAndLastPDF field. Add a step that sets a text field to your filepath before saving the PDF. Then compare what's actually in this field with the correct path you get by inserting the file into a container (as reference only). This is the third time I am suggesting this. Link to comment Share on other sites More sharing options...
milky Posted September 30 Author Share Posted September 30 Finally got the script to work: #Set the desktop path Set Variable [$desktopPath; Value: Get ( DesktopPath )] #Set the full file path via the desktop path Set Variable $ChartPath; Value: Get ( DesktopPath )] #Set the Players First and Last name and the .pdf extension Set Variable $playerName; Value: Players::FirstAndLastPDF] #Setup the Printer Print Setup [Restore; With dialog:Off] #Microsoft Print To PDF #A4 #Landscape #Save the current record as a PDF Save Records as PDF [Restore; With dialog: Off; "$playerName"; Current Record; Create Folders: Off] #Output file path List: file:BPU Website - 2024/Charts/$playerName #Specify Options: Specify Options: Save - Current Record, Options: Specific Pages - 1 through 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now