1 2 Previous Next 16 Replies Latest reply on Mar 20, 2012 8:36 AM by stinchy

    Auto Insert File into a Container Field without knowing the filename in advance

    stinchy

      Is there a way to auto insert a file into a container field without knowing the filename in advance ?

       

      Basically I have folders ( which are set as variables by an existing script ) which have a single file in them. The filenames are random in nature.

       

      I need to insert the file in a container field ( reference only ) and have filemaker select the single file from the folder specificed ( by the variable ) and reference this single file without any user interaction.

       

      Is this possible ?

       

      I am using FileMaker Pro Advanced 11 and the above only needs to apply on a mac.

       

      Hope the above makes some kind of sense . . . . .

        • 1. Re: Auto Insert File into a Container Field without knowing the filename in advance
          RubenVanDenBoogaard

          Hi,

           

          If these are pictures or text files and you know the path to the folder you can import all the files into a table using the import Folder command. then use the folderpath of the file to do other tricks.

           

          Otherwise you could use a plugin like the (free) 360Works Scriptmaster plugin to read the contents of the folder and go from there.

           

          Best regards,

           

          Ruben van den Boogaard

          Infomatics Software

          ruben@infomatics.nl

          • 2. Re: Auto Insert File into a Container Field without knowing the filename in advance
            comment

            stinchy wrote:

             

            I need to insert the file in a container field ( reference only ) and have filemaker select the single file from the folder specificed ( by the variable ) and reference this single file without any user interaction.

             

            What is the purpose of inserting the file into a container field? Isn't it enough to store the path to the parent folder of the file?

            • 3. Re: Auto Insert File into a Container Field without knowing the filename in advance
              Stephen Huston

              I have done something a little like what you describe, but still requiring the user to specify the folder name (if on the Desktop) or the file-Name, via a dialog box field which is then used in a variable in the import script.

               

              Some user interaction is required if the file-path is not known in advance and cannot be encoded in the script.

              • 4. Re: Auto Insert File into a Container Field without knowing the filename in advance
                stinchy

                Hi Everyone,

                 

                Thanks for the initial replies.

                 

                In order to give a little more clarity to my needs I have summarised below my ultimate aim :-

                 

                I Currently I drop an email (.eml) from Outlook 2011 (mac) into a folder on my desktop.

                 

                I then press a button from within Filemaker which runs a script which creates an event with unqiue number with my table.

                 

                The script then runs an applescript which moves the email from the desktop folder and creates a folder on our network ( using the unqiue number as the folder name ) and moves the email into this folder.

                 

                So far so good.

                 

                However what I need to achieve next is for Filemaker to some how reference this email in a container field so that when the user see this event they simply need to click the container and it will open up the email ( natively through outlook ).

                 

                I have considered renaming the email whilst it is getting moved to a standard name e.g. Email.eml so that I can then easily reference the location and filename. However I really want to keep the original filename ( which is based on the subject from the email ) as this can then be copied to another field in filemaker as a description for the event.

                 

                Not sure if this would need to be done at the applescript stage or not ( if so any idea how this could be done ).

                 

                Hopefully the above summary will shed a little more light on my aim.

                 

                Thanks again everyone for your input - much appreciated.

                • 5. Re: Auto Insert File into a Container Field without knowing the filename in advance
                  comment

                  stinchy wrote:

                   

                  However what I need to achieve next is for Filemaker to some how reference this email in a container field so that when the user see this event they simply need to click the container and it will open up the email ( natively through outlook ).

                   

                  Why can't they click a button that will run an AppleScript to open the e-mail in Outlook?

                  • 6. Re: Auto Insert File into a Container Field without knowing the filename in advance
                    stinchy

                    Hi Michael,

                     

                    This would correctly achieve the opening of the file, however it will not give me the ability to see the filename or copy the filename to a description field in my table.

                     

                    The record which will store the container field ( reference only ) has other fields such as date, time, description etc and appears in a portal. The portal is part of a CRM type section of my solution which the user stores notes, attachments etc. What I need them to see is the description of the email - if they then click the record ( I have a little email icon which is the button ) it opens the referenced email.

                     

                    I can easily have the user manually reference the email but I would really like to automate it as this makes the experience smoother and quicker.

                     

                    As mentioned previously I have the path to the actual folder - it's the email file ( more specifically it's filename ) that is giving me the issue.

                     

                    I am looking into trying to get an applescript to copy the filename ( to the clipboard ? ) whilst it is moving the file and somehow pasting it into a field within filemaker - this would then allow me to copy this new field and add it to the path reference. However I am totally new to applescript ( or shell script ) and was hoping someone would know how this can be done or even better if filemaker can do it without applescipt ? There will only ever be one file (email) per event stored in the already create folder.

                     

                    I am not concerned if the way to open the file is from a referenced container field or not, but the user experience should be the same - they click the portal row ( which displays the description ) and it opens the email in outlook.

                     

                    Sorry for the information overload !!!!

                    • 7. Re: Auto Insert File into a Container Field without knowing the filename in advance
                      comment

                      stinchy wrote:

                       

                      I am looking into trying to get an applescript to copy the filename ( to the clipboard ? ) whilst it is moving the file and somehow pasting it into a field within filemaker

                       

                      Yes, that would be the way - except you don't need copy/paste: AppleScript can tell Filemaker to:

                       

                      set  cell "FileName" of current record to name of myFile

                       

                      or something similar.

                      • 8. Re: Auto Insert File into a Container Field without knowing the filename in advance
                        stinchy

                        That may work - I now need to find out how to copy the filename to the clipboard first !!  any takers ?

                        • 10. Re: Auto Insert File into a Container Field without knowing the filename in advance
                          comment

                          stinchy wrote:

                           

                          That may work - I now need to find out how to copy the filename to the clipboard first !!  any takers ?

                           

                          As I said, you do not need to copy/paste. Nor should you, because by doing that you destroy the user's clipboard.

                          • 11. Re: Auto Insert File into a Container Field without knowing the filename in advance
                            stinchy

                            Hi Michael,

                             

                            I now understand the need not to copy and paste and the issues it may cause.

                             

                            May have to re-think the whole process ?

                             

                            If I can't get a slick automated way to link the file in then I may have to resort to renaming the original file as it gets moved to a generic name (Email.eml) and this will allow me to reference the file.

                             

                            The user will have to manually enter a description for the record.

                             

                            Not ideal, but unless someone can suggest an alternative I may have to investigate this instead.

                             

                            Really would have been nice if FileMaker could let you suggest the path of the file and automatically select the first file in path and reference it.

                             

                            Will keep on trying . . .

                             

                             

                            Thanks again.

                            • 12. Re: Auto Insert File into a Container Field without knowing the filename in advance
                              comment

                              Perhaps it would help if you posted the process by which the file gets moved. I don't see how it can be moved without knowing its name - and if it is known, it can be stored in a field.

                              • 13. Re: Auto Insert File into a Container Field without knowing the filename in advance
                                stinchy

                                Michael,

                                 

                                I have two calculated applescripts :-

                                 

                                First makes directory based on an "activity_reference" field :

                                 

                                "do shell script \"mkdir -p /Volumes/Backups/Attachments/\" & quoted form of \"" & ACTIVITIES::activity_reference & "\""

                                 

                                The second moves the contents of the desktop folder to the newly created folders :-

                                 

                                "do shell script \"mv '/Users/clive/Desktop/Transfers/'* '" & $foldername & "'\""

                                 

                                The $foldername is a filemaker variable that stores the location of the newly created folder.

                                 

                                Therefore at no point in the scripts does it actually store the filename as so far it simply created a unique folder and moved all the files from the desktop folder to the new one.

                                 

                                The above scripts will in fact move all contents of the desktop folder to the new location - however the process I intend to use will only have one file at anytime.

                                 

                                I think I then need some kind of script to go into the newly created folder ( which now has the file in it ) and get the filename from there - again not sure if an applescript / shell script or filemaker script will do this.

                                 

                                If I could only manage to get the filename then I am sorted.

                                1 2 Previous Next