7 Replies Latest reply on Mar 11, 2012 5:14 PM by lhoong

    Inserting files as objects into a container with a script step?

    smoothie

      Hi;

       

      I'm a bit a nubie on FM, but an old hand with VB, SQL, etc. What I'm tring to do is allow a user to click on a portal row to select a file who's path is stored in a related table field into a global container field in the current table, so they see the contents without having to store every doc in the related table. Can anyone shine the light for me?

       

      Thanks!

        • 1. Re: Inserting files as objects into a container with a script step?
          techt

          What do you want to do with the file - open it? You can store a file in a container as referenced file, so it isn't actually in the database itself. That will help on size and potentially remove the need for second file. Since the files are only referenced, why move the related link into a global in the first file? Why not just leverage the relationship and open the file from the first?

           

          This probably raises more questions than answers, but you'll find everyone here willing to help.

           

          Tim

          • 2. Re: Inserting files as objects into a container with a script step?
            lhoong

            smoothie,

             

            If the purpose is to allow the user to preview the selected file, you can use a web viewer object instead of a global container field. You can set the web viewer Web Address (URL) to the file path in the form of:

             

            file://myHD/directory1/subdirectory2/daFile.pdf

             

            If the filepath is stored in a container field (e.g. TOC::PathField), the Web Address calculation may look like:

             

            Substitute ( GetValue ( myTOC::PathField ; 2 ) ;

             

            Case (

             

            Abs ( Get ( SystemPlatform ) ) = 1 ; "filemac:/" ;   //Mac platform

             

            Get ( SystemPlatform ) = 2 ; "filewin:/" ;   //Win platform

             

             

            ) ;    //end Case

             

            "file://" )  //end Substitute

             

            Depending on the file type, your mileage will vary in terms of whether the file will preview and how much scrolling the user will have to do to view the content. On a Mac, .pdf previews quite well.

             

            HTH.

             

            Lee.

            =================

            Binary Assist

            220 Gaines Oak Way

            Suwanee, GA 30024

            Voice: (678) 313-5604

            Internet: lhoong@binaryassist.com

            Website: www.binaryassist.com

             

            FileMaker Certified Developer

            • 3. Re: Inserting files as objects into a container with a script step?
              lhoong

              Oops, my bad. The web viewer Web Address calc. should be:

               

              If the filepath is stored in a container field (e.g. TOC::PathField), the Web Address calculation may look like:

               

              Substitute ( GetValue ( myTOC::PathField ; 2 ) ;

               

              Case (

               

              Abs ( Get ( SystemPlatform ) ) = 1 ; "filemac:/" ;   //Mac platform

               

              Get ( SystemPlatform ) = -2 ; "filewin:/" ;   //Win platform

               

               

              ) ;    //end Case

               

              "file://" )  //end Substitute

               

               

              The Get ( SystemPlatform ) result for Windows is a negative value.

               

              Lee.

              =================

              Binary Assist

              220 Gaines Oak Way

              Suwanee, GA 30024

              Voice: (678) 313-5604

              Internet: lhoong@binaryassist.com

              Website: www.binaryassist.com

               

              FileMaker Certified Developer

              • 4. Re: Inserting files as objects into a container with a script step?
                smoothie

                Ideally, I'd like to have a container on the right of a portal containing a list of docs of all types attached to the record on the left.  Click on a portal record and have the script load the doc into the global container on the right, rather than opening the file in the native application until the user sees that the doc they've selected is the one they want to use.  I was also thinking that it would be good to be able to use the OLE functionality to allow the user to edit a doc right in the container if they want and use a script step to save it.....  user745's suggestions sounds like it may just do the trick well enough, although it wouldn't let you edit in, it would let you look at most doc types.

                • 5. Re: Inserting files as objects into a container with a script step?
                  lhoong

                  smoothie,

                   

                  Please be aware that future versions of FileMaker Pro may no longer support OLE. See here:

                   

                  bit.ly/w4r1AH

                   

                  Lee.

                  =================

                  Binary Assist

                  220 Gaines Oak Way

                  Suwanee, GA 30024

                  Voice: (678) 313-5604

                  Internet: lhoong@binaryassist.com

                  Website: www.binaryassist.com

                   

                  FileMaker Certified Developer

                  • 6. Re: Inserting files as objects into a container with a script step?
                    smoothie

                    Hi Lee;

                     

                    I've tried your suggestion, but get nothing but errors from the web control when I point it to a word doc, excel file, etc.  I've replaced \ with / in the path, tried adding "http://localhost/file://" to the front of the string, etc. but all to no avail.  how do you get the web viewer to display a document for an application on your box?

                     

                    I think the ideal would be to be able to insert the file as an object into a global container field

                     

                    Thanks for your help.

                    • 7. Re: Inserting files as objects into a container with a script step?
                      lhoong

                      smoothie,

                       

                      I've attached a .zip archive that contains a file (PreviewContainer.fp7) to illustrate previewing a file using a web viewer object.

                       

                      Please note that on the Mac, graphics files (png, jpg, etc.) and PDFs preview correctly, but MS Word and Excel files do not. I have not tested this sample Db in Windows, so I'm not sure if the behavior will vary.

                       

                      HTH.

                       

                      Lee.

                      =================

                      Binary Assist

                      220 Gaines Oak Way

                      Suwanee, GA 30024

                      Voice: (678) 313-5604

                      Internet: lhoong@binaryassist.com

                      Website: www.binaryassist.com

                       

                       

                      FileMaker Certified Developer