4 Replies Latest reply on Jan 5, 2016 1:18 PM by electon

    Automating Import of Files

    maddie

      A client wants to automate the self import of files into his database. I think I'm on the right track, but whenever I test the script, I keep on getting error 100 (File not Found). I know that's not right because when I open the folder the file is in there. They have multiple files to upload, but the variables are similar, here is what one looks like:

       

      "filemac:Macintosh HD/Users/amk/Desktop/Client Files/" & Clients::Folder & "/" & Matters::Matter ID & "/" & "correspondence." & Matters::Matter ID & ".pdf"

       

      In the finished version, the script will know wether the user is on a windows machine or a Mac and will populate the variable accordingly. Any of the variables will look like this when populated:

       

      filemac:Macintosh HD/Users/amk/Desktop/Client Files/Able Studios/INV.800/correspondence.INV.800.pdf

       

      I cannot change the file name as they want to keep their filenames consistent.

       

      Below is the script that I'm working on:

      Screen Shot 2016-01-05 at 10.14.29 AM.jpg

       

      Any idea what is going wrong?

        • 1. Re: Automating Import of Files
          electon

          It's actually filemac:/volumeName/directoryName/fileName

          Try adding the first backslash right after the filemac:

          • 2. Re: Automating Import of Files
            electon

            I'd like to point some other stuff out, if you don't mind.

             

            You're hard coding the volume name to "Macintosh HD".

            The problem is that ( in some rare cases ) it can change from machine to machine or even on the same machine.

            When doing a clean install you can give the volume a name of your choosing or in Finder highlight the volume > Get Info and change it there, So it's not a thing you can always count on. Chances are low but it can happen.

             

            It would be bullet proof if you use Get Directory () script step so the user can at least choose the base folder.

            Another way is to scrape out the volume name from another function like Get ( DocumentsPath ) first and build your path from there up.

             

            If you don't mind me asking, where does the NotDev in you window parameters come from. Is it a field? not a variable as far as I can read.

            It's just that I've rarely seen a negation in such cases. NotDev must evaluate to true so it has to hold a boolean value to determine if the file is in developer's hands. An empty value will evaluate to false.

            Hopefully, most of the time it won't be, so it seems just like wasting resources.

            You always need to remember to set it to true for production or false, regardless.

            If you forget to do it it will default to developer mode which is somewhat odd.

            If ( Dev ; then this and that ) I would think.

            • 3. Re: Automating Import of Files
              maddie

              Using filemac:/ fixed the problem.

               

              The reason why it's hardcoded is for my personal testing. Now that I've gotten it to work, I have updated the script to use the file path that the user has provided. There is a file path field that they can type into and set their own path so when the database is launched, the file path is grabbed at startup as a global variable, and when they go to do the auto import, it will know where to go. I've also made sure to include the type of the machine (windows or mac). The reason for a completely customizable file path is not all users that I know use the documents folder.

               

              NotDev is a custom function that I've been using for a year or so, the calculation goes along the lines of this:

               

              Get ( AccountPrivilegeSetName ) ≠ "[Full Access]"

               

              In other words, during a script if a offscreen window is brought up and they're not a Full Access user then it's shoved off screen and closed when the script is over. If the user is Full Access the new window stays visible to the user so then they can see the data and what is happening.

              • 4. Re: Automating Import of Files
                electon

                Glad you got it working and thanks for the explanation. Interesting implementation with a custom function.