6 Replies Latest reply on Oct 17, 2014 7:10 AM by grouper

    container, multiple files and storage path



      container, multiple files and storage path


      Hi all

      My database basic structure outline is : clients-------<appointments----------<data. I 've set up table occurrences and everything works ok with that. One of the data fields is a container, which I 've put in a portal. Basically, how it works is the user drags a file into the portal and creates a new object for that appointment.

      Container files are saved externally, in a path relative to the DB. It is very important for the overall functionality to automatically create structured subdirectories in this external path that make sense, so that the user can go on and access the container objects even without opening the database. So i 've created a script that automatically generates a path and saves each object that is dragged into the container field. It goes like : /containers/clientname_id/appointmentdate/[object]. This works fine.

      Many clients come with data on a CD/DVD that contain multiple files that are unreadable by FM (i.e. dicomm images). All these images are on a specific folder, which I 'd like to drag and drop on a DB container field; not for viewing them directly through FM, but for automatically saving them in the client&date specific directory, which the user can access. The DB would just let him know that such files exist in that directory. It seems that the container field cannot receive a whole folder.

      Is there any way around this?




        • 1. Re: container, multiple files and storage path

          A simple drag and drop won't do it.

          You'd need to use a script to insert the items from that folder one at a time or you'd need to zip the folder so that the zipped folder can be treated by Filemaker as a single file.

          There are ways to get a list of all files in a folder so that a script can loop through them and insert them one at a time into different records in Data. there are plug ins, a system script can generate a text file list of the file  names for import into FileMaker or you can use a folder inside Documents and use Get ( DocumentsPathListing ) combined with some parsing to get to the file names for each file.

          • 2. Re: container, multiple files and storage path

            thanks Phil

            a couple of questions relevant to the above :

            1. Is it possible to generate a script (FM pro 12) that gets the list of all files in a windows folder other than //Documents or would i need a plug in for it? I 'd like to avoid the plug-in because i 'm not sure that functionality would be preserved in remote access via Filemaker Go.

            2. Is there a way (script or other) to tell FM to save a simple empty .txt (or similar format) file with a name that the user would define each time at a calculated directory?

            3. My containers are stored externally at a  calculated path relevant to the DB. I 'd like to give the user the option to go to this path via the OpenUrl function. I found an earlier post of yours regarding this at http://forums.filemaker.com/posts/6239bd2f11  :

            "Define calculation fields that returns text and use these expressions to return the file path of a store by reference file:

            cFilePath: GetValue ( containerField ; 2 )
            cFileName: Middle ( cFilePath ; Position ( cFilePath ; "/" ; Length ( cFilePath ) ; - 1 ) + 1 ; 999 )

            this works only when a reference is stored. For external storage, i tried manipulating the GetValue function, by changing the number from 2 to 4, but still, the first word that appears in the path is the type of the container data, i.e.  "JPEG:/Container_Field_1/client1_16032800266/27_8_2014/24248452.jpg". I tried to manipulate the Middle function in order to start from the 7th letter, but this isn't going to work if the container file is in a different format i.e. BMP. How can I get the path only?

            4. Is there a way to rename container fields according to a caclulation/script without having to import and export?



            • 3. Re: container, multiple files and storage path

              1. Go doesn't use plug ins but you can't do drag and drop anyway in Go.... And the alternative is a system script--which won't work from Go either, I suspect (haven't tried that). But you might be able to get something to work "server side" for this if you are hosting the DB and your iOS devices connect as clients of the hosted database.

              2. FileMaker can generate text files using  export field contents and using Export Records. (I've performed batch files and VBScripts by using Export records to generate a text file with the needed file extension. By selecting the "open" option, the export also then performs the batch file or VB Script to get something done that can't be done with a fileMaker script.)

              3: see the calculations found in the following thread if you want to extract a filepath or filename from a field with external storage:Exploring the use of a $Path Variable in Scripts

              4. why would you rename a FIeld? don't you want to rename the file inserted into the field? And no, it has to be exported and re-inserted as far as I know...

              • 4. Re: container, multiple files and storage path

                Sorry, I meant renaming a file in a container field, but you answered it anyway,

                thanks a lot Phil


                EDIT : i had a look at the link, - and it seems that the issue of getting the path is a bit complicated. Drag and Drop in containers would not be the same as by using the insert function; also, if i understand correctly, things are different when the objects are stored externally (vs when a reference only is used). I 've manage to compile a script to get the path using a combination of various functions (get filepath, get filename, get value, length, midlle, etc) in order to manipulate the text and get the desired result, but it still only works for some container files types (not pdfs). So, my only working complete solution for now is to get the predicted file path, -based on finding the directory in which the DB should have externally saved the containers files according to a calculation during the import process.

                again thanks a lot for taking the time to answer my questions.

                P.S. i think that it would be nice to have a function like Get(ContainerPath) in the next editions of FM.


                • 5. Re: container, multiple files and storage path

                  The calculation used in that file is complex because it is designed to work with all storage options and insertion methods. But you can also set up the container field in that file to have external storage, insert a file and then examine the text that appears in the fields of that file to produce a much simpler calculation that only works with external storage.

                  Drag and drop is the same as embedding a file using insert picture. The issue you were setting yourself up for is that you can't drag and drop a group of files or a folder filled with files so I've suggested alternatives that can produce the result that you want.

                  • 6. Re: container, multiple files and storage path

                    After changing the container storage options for both fields to external---open, i get the message "FilePaths to files in externally stored, secure container fields are not accessible". Maybe in order for this to work i should make changes to more calculated fields?

                    edit : i 'm talking about single file insertion, i 'm trying first to get past that before attempting multiple files.