7 Replies Latest reply on Jul 3, 2015 12:58 PM by philmodjunk

    script to create a PDF, then put it in a container field as new record

    jdevans

      Title

      script to create a PDF, then put it in a container field as new record

      Post

      I have a script in a solution that is SUPPOSED to do as the title of this post suggests. It works fine on my machine, and a couple others, but on some network machines, it fails. I'm unsure why it works on some machines and not others.
      What is happening is, a user clicks a button, which runs the script. It first checks for data, for the that the records exist, then it shows the found set on a printable layout. The script pauses for the user to make one last check over what they are about to create (on the PDF), then if they click the "continue" button, the script continues and creates a pdf of the record using the layout specified, and to make sure it is accessible, it goes to the "Temp" folder on the server and puts the pdf there.. This server is accessible by all users, and the Temp folder is accessible to by going to "//ServerName/Temp/file.pdf."

      This is what is strange to me. I guess I'm asking if there is another way to create a new record of this pdf besides making on a network folder first, then grabbing it and making a record of it? Could it be done without the use of a network folder? If it could be done on the user's local machine, are there script steps available to create a local directory, place the pdf there, then make the new record from there? Or is this more complex than it needs to be?

       

        • 1. Re: script to create a PDF, then put it in a container field as new record
          philmodjunk

          How exactly does this fail on the machines where it doesn't work?

          What you describe would only work if all users have "write" permission to that temp folder and the filepath to that folder is mapped/mounted to be the same for all users--something not always possible if some machines are macs and others windows.

          But there's no need to use that temporary folder. Your script can use the temporary folder on each client machine and insert the PDF into the container from there instead of the temp folder on the server.

          • 2. Re: script to create a PDF, then put it in a container field as new record
            jdevans

            As I have begun to dig into the issue, I found that the user can see the contents of the Temp folder, but doesn't have write access to it. I tried to create a txt file inside that directory from an errant machine, and it failed the Windows Permissions test.

            Our network admin says that this user, and others apparently, have been given the same permissions to that folder that my machine has, but for whatever reason, from the perspective of the client machine, the write access is denied.

            This has me wanting a different way altogether of creating these pdf records, since it is unpredictable what will happen trying to do it on a shared network folder.

            So, to your suggestion Phil, is it a certainty that every machine is going to have Temp folder defined the same way, or is there a way to have the script "find" the Temp folder first, before it is used. It could be that some of our users have monkeyed with the location of the Temp folder. Not saying that it HAS happened, but I wouldn't be surprised.

             

             

             

            • 3. Re: script to create a PDF, then put it in a container field as new record
              philmodjunk

              Due to differences in OS and user accounts, it will be different every time, but if you use the Get ( TemporaryPath ) function, you can get the file path to it for the local machine without having to explicitly state it.

              • 4. Re: script to create a PDF, then put it in a container field as new record
                jdevans

                So, I used the Get (TemporaryPath) function, and it failed. I think I have a problem with the Domain Account privileges in Win7. I also found and tried Get(DesktopPath) and encountered the same. My machine was recently wiped clean and re-installed, so I think there may be a problem that began there.

                Side-note/question: is there a way to delete the file in the temp path at the end of the script so that nothing remains except the record in the container field? I've searched the built-in functions, and the custom-function site, but haven't found anything that looks like it will work. I just need a "clean-up" routine at the end of the script.

                 

                • 5. Re: script to create a PDF, then put it in a container field as new record
                  philmodjunk

                  I suggest that you spell out the details of how it failed unless the following links solve the issue(s) for you. Perhaps it was not implemented correctly. It would seem to me very unlikely that Get ( TemporaryPath ) or Get ( DesktopPath) would fail on any machine where you have FileMaker Installed unless something pretty major was wrong with your OS install or OS based user account settings.

                  See this thread for an example script using Get ( DesktopPath ). You could substitute Get ( TemporaryPath ) in the example script and get the same results only the PDF gets saved to the Temp folder instead of the desktop. (I'd use Get ( DesktopPath) during initial tests and then switch to the temporary folder once I see that the PDF is being successfully created on the DeskTop.)

                  Found Sets to PDF with unique file names

                  And if you want to learn more about $Path variables, Container fields, file paths and the script steps that can use them, see: Exploring the use of a $Path Variable in Scripts for an "exploration file" that illustrates a number of key details and which can be used to determine actual file paths to specific locations on your computer.

                  • 6. Re: script to create a PDF, then put it in a container field as new record
                    jdevans

                    Thanks Phil. On top of everything else, I was having internet issues as well, so posting a screenshot of the error message was not happening. I'll read thru the links, and see if I can work through it. The gist of the script does some of what is suggested there ( I scanned thru the links to get an idea of what others are doing). I really believe it has more to do with the re-install of my OS at this point and the way the User Accounts were set up.
                     But do you know of a function that will allow me to do a file-delete from the temp location after the pdf is inserted into a container field? I was looking at the Script steps that are sorted under "Files" but I figured those were more "filemaker files" related than OS files (.pdf, .txt, etc).

                     

                    • 7. Re: script to create a PDF, then put it in a container field as new record
                      philmodjunk

                      As answered in the new thread that you opened. when you save to the temporary folder you don't need to delete files from it as they do not persist in that folder. That's why they call it the temporary folder after all. wink