7 Replies Latest reply on Oct 31, 2016 1:06 AM by BruceRobertson

    How to insert multiple files with a button - calculation help needed

    southernkross

      Hi guys. I’m a Filemaker newbie and I need so help with a calculation. Forgive me if this is a stupid question.

       

      I want to be able to attach multiple documents (excel, PDF etc) to my database through use of a button and display them in thumbnail form in container(s).  I want others to be able to click on these documents and open them with the corresponding program.

       

      I have made a button called “attach file” and it has the following script:

       

      Insert File [Filters; Reference; Never Compress; Content Management:: attached documents1]

       

      “attached documents1” being the container that I wish to display the thumbnail.

       

      That all works fine, but what I would like is to insert up to 3 files. Because it seems there isn’t a way to display more than one file in a container(?), I have created additional containers named “attached documents2” and “attached documents3”.  I realise now I need add in a conditional calculation to attach a second document. The idea being if “attached documents1” already contains a file, then that second file will be inserted into “attached documents2” (and so on).

       

      This is as far as I’ve gotten:

       

      Case ( not IsEmpty ( Content Management::Attached documents1 );  )

       

      How can I complete this calculation or is there a better way to do this?  Any other advice is welcome.

       

       

      Just as a note: I’ve been dropped in the deep end and have had to basically figure out FM completely on my own without any instruction or a proper tutorial (I’ve actually lurked in this forum a lot for help figuring things out, so thanks for that!). I know very little about calculations beyond the bare basics, so feel free to talk to me like I’m an idiot when you explain this stuff - I won't be offended.

        • 1. Re: How to insert multiple files with a button - calculation help needed
          philmodjunk

          It's only one file to a container field.

           

          I suggest setting up a table of related records for your files. Then you can use a portal for this and users can then attach a fully flexible number of files to a given record.

           

          Your button's script can then create a new related record and insert a file into it. This also eliminates the need to check each field in turn to find one that's empty.

          • 2. Re: How to insert multiple files with a button - calculation help needed
            southernkross

            Thanks for your reply. That's a good idea that I never thought of.  I'm a little uncertain about how that would be scripted, though. I tried a couple of different things but it didn't work. Could you be specific?

             

            I should have mentioned that I'm placing that portal in a popover button. From what I understand this shouldn't be a problem.

            • 3. Re: How to insert multiple files with a button - calculation help needed
              Fulvio Di Rosa

              The answer of philmfdjunk is correct. As relational database FM need a Table (Type: ID Customer,Name, Surname ... etc.) and another Table Documents (Type: ID Document, ID Customer, Container). So one Customer has many Documents and this table is in a portal row. I have only a problem in this same case: Server Win and clients WIN/MAC.

              the Win clients put in container PDF documents as referred directory on server and open it in Acrobat directly with a double click; the Mac clients, else, can only export it to their own Apple. Why ??

              • 4. Re: How to insert multiple files with a button - calculation help needed
                philmodjunk

                If the create option is enabled for the relationship....

                 

                assign an object name to the portal using the inspector.

                 

                In your script:

                Go to object ["objectnameofPortalHere"]

                Go to Portal Row [ Last ]

                Insert Field [specify container field in portal row here]

                 

                Note that this script will open your popover with the go to object step if it is not already open.

                • 5. Re: How to insert multiple files with a button - calculation help needed
                  BruceRobertson

                  " I'm a little uncertain about how that would be scripted, though. I tried a couple of different things but it didn't work. Could you be specific?"

                   

                  Conversely; how about YOU be specific?

                  Consider providing a copy of your script; or a simplified example file which illustrates what you have attempted.

                  It is very difficult to provide meaningful replies to "I tried something but it didn't work."

                  • 6. Re: How to insert multiple files with a button - calculation help needed
                    southernkross

                    Sorry bruce but I didn't the things I try are of much help because I don't really know what I'm doing and will make obvious mistakes.

                     

                    I tried your script phil and it opened the popover button box but no dialog box (for inserting the file) appeared.

                     

                    So I also tried a couple variations of that. This is the first one:

                     

                    Go to layout [documents" (documents)]

                    New record

                    Go to portal row (first)

                    Insert File [Filters; Reference; Never Compress; documents::document container]

                     

                    This unfortunately opened the portal in a whole new layout. The insert file dialog box appeared and I was able to insert a file but it didn't appear in the in the popover button portal when i returned to it.

                     

                    So I did the same script with go to layout [original] added in the 3rd row. It did the same thing as before - it went to the portal but no dialog box.

                    • 7. Re: How to insert multiple files with a button - calculation help needed
                      BruceRobertson

                      "Sorry bruce but I didn't (think) the things I try are of much help because I don't really know what I'm doing and will make obvious mistakes."

                       

                      Then it is hard to see how you expect this to work. It is understood that you are making mistakes. It is the particular and exact details of your mistakes that we need to see.

                       

                      If you just keep saying "I tried something and it didn't work" then we cannot help you.

                      Please either attach your file; or create a simplified version of your file; and attach it.

                      Then somebody can actually help you.