12 Replies Latest reply on May 23, 2016 2:32 AM by erolst

    Moving container to a field on another table

    theharrisonlee

      First of all please bear with my terms i am a complete beginner to FM,

       

      Basically the situation is I have many different forms (more than 30) and they all require attachments (photo or pdf) to them.  So I thought it would be wiser to have another layout called Attachment to do this.  So user on the Form layout could click on a button and then would take them to the Attachment Layout and use that to insert photos or pdf files.

       

      The question is i am having trouble copying and pasting the photos inside the container back and forth.  How do you set the container to a global variable and how do you use that to put back into a field??

       

      It would be very kind of you if you could provide me the scripts needed to do that.

       

      Thanks so much for your help!!!!!

       

      Screen Shot 2016-05-22 at 10.27.18 PM.png

       

      here are the codes i have so far but obviously they don't work at all. 

       

      Your help is greatly appriciated!!!!!!

       

      Harrison

        • 1. Re: Moving container to a field on another table
          erolst

          theharrisonlee wrote:

          The question is i am having trouble copying and pasting the photos inside the container back and forth.

          Why would you want to copy anything around, much less back and forth?

           

          The idea of an Attachment** child table would be to have one central place to store media files – as many as desired for any one parent – and relate them to a parent (or several).

           

          The credo of a relational database system is: store in one place, reference in many others.

           

          The next question is: why do you have 30 different layouts? Are they all based all different tables, or just variations of the same layout? There is (at an educated guess) lots of potential for unification, which would allow you have fewer layouts and simply use a portal (which is the simplest way to add related records).

           

          btw, even in the rare cases where you need to shuffle data around, you should avoid using the clipboard, as it a) requires the involved fields to be on the layout, and b) overwrites your user's (or your own) clipboard, which can lead to nasty surprises.

           

          The idiomatic method in FM is to use the combination of Set Variable [ $someVar ; SourceTable::sourceField ] and Set Field [ TargetTable::targetField ; $someVar ]

           

          e.g.

           

          Set Variable [ $media ; VO_forms::att1 ]

          Go to Layout [ Attachments ( Attachments ) ]

          New Record/Request/Page

          Set Field [ Attachments::p1 : $media ]

           

          Of course, now you'd have an Attachments record with contents, but not belonging anywhere … and would have stored that content twice.

          1 of 1 people found this helpful
          • 2. Re: Moving container to a field on another table
            keywords

            Don't use Copy and Paste. These are clumsy instruments that use the computer's clipboard and can easily go wrong for that reason. Instead use SetVariable and SetField, something like the following:

             

            where you have Copy use—Set Variable [ $containerContent ; Value: VO_forms::att1 ]

             

            where you have Paste use—Set Field [ Attachment;;p1 ; $containerContent ]

            1 of 1 people found this helpful
            • 3. Re: Moving container to a field on another table
              theharrisonlee

              First of all I would like to thank you all for giving a providing a helping hand to my problem, which is extremely kind of you guys.

               

              The script you provided for the moving containers helped me out of my mysteries so much and now have a better idea regarding the handling of containers.

               

              Well regarding the question why i need so many layouts, its because the situation is that the company has 30+ different types of forms (all have different purposes) , and each individual form may need attachments (photos or pdf) to it for references.  So therefore initially I thought it would be a nice idea to have a separate layout to handle the attaching mechanism and use it for all the different types of forms.  (so in future when i need to make changes to the layout of the Attachment i don't have to go through every single form and have them changed).

               

              But now i think sticking to the method of doing the attachment in the form itself would be so much easier.  However I am not sure you would agree with that?? And would that be the case in the professional world??

               

              Many Thanks

               

              Harrison

              • 4. Re: Moving container to a field on another table
                keywords

                From what you describe now, it seems to me that if you have a number of forms stored as PDFs, you would be better to store all your forms in a separate table and simply reference them as needed on each layout, instead of moving them from field to field as you originally proposed.

                 

                If you have a pdf form on a layout and need to fill in information on it, you can easily place relevant fields over the top of the form, to place the detail in the correct places on the form.

                • 5. Re: Moving container to a field on another table
                  theharrisonlee

                  Sorry for the my bad descriptions, the forms are not pdf files, i actually created them on separate layouts looking like this

                  Screen Shot 2016-05-23 at 4.22.03 PM.png

                   

                  and i have tones of them.  And I have each individual type of form stored on separate tables at the moment, and using different layouts for inputting data into each particular form.  But the attaching procedure would be the same thought all the different types of forms.

                  • 6. Re: Moving container to a field on another table
                    keywords

                    Still not clear. Can you post a screenshot in layout mode?

                    • 7. Re: Moving container to a field on another table
                      theharrisonlee

                      the screenshot above is a layout mode ( every box is an edit box/combo box for a field) .  I created the whole page using edit boxes and combo boxes

                      • 8. Re: Moving container to a field on another table
                        erolst

                        Now please show us the field list (Manage Database) of that table.

                        • 10. Re: Moving container to a field on another table
                          keywords

                          Sorry, but I lose interest at this point. Twenty two text fields named simply t1 – t22 speaks volumes. Give you fields meaningful names! In doing so your own structure and purpose may become clearer to yourself.

                          • 11. Re: Moving container to a field on another table
                            theharrisonlee

                            thanks so much for your help anyway, I appreciated it very much. 

                             

                            I will carry on and have my database improved first.

                            • 12. Re: Moving container to a field on another table
                              erolst

                              I suspected something, but not that