6 Replies Latest reply on Jun 15, 2016 3:12 PM by shauncooper

    Hiding an object using scripts

    shauncooper

      Hello All,

      I'm new to FileMaker and hoping somebody out there can help me. I'm trying to figure out how to hide objects in a report with blank fields by using scripts.  I'm okay up to the "Hide Object Field" in the Inspector  but don't know what to do in the "Specifiy Calculation" window.

      The fields that I'd like to hide are text, number and container fields--what scripts should I use for each and what conditions should I specify?

      Thanks for any help you can provide, it's not easy for a newbie.

      Cheers

        • 1. Re: Hiding an object using scripts
          Mike_Mitchell

          If it's a report, then you are probably better served with the Sliding feature, rather than Hide Object. Hide Object will not remove the blank space from inside a missing element; it will just sit there.

           

          It's not a script; it's a setting in the Inspector (Position tab, under Sliding & Visibility):

           

          Screen Shot 2016-06-14 at 6.54.05 PM.png

           

          HTH

           

          Mike

           

          (P. S. If you let us know exactly what your requirement is, we can probably give you a more precise answer.)

          • 2. Re: Hiding an object using scripts
            ch0c0halic

            Think of the layout formulae as applying to the field for each record as its displayed/printed. In a script you could set a global variable but then it's applying to every record. So you don't normally hide a field from a script.

            So the field will be hidden for ALL records, not just the current one the script may be addressing.

             

            This is for a report so I'm assuming you are printing it. A blank field being empty doesn't print or display anything because it's empty.

            You say you want to hide the field if its empty? But, what happens to the 'white space' left in its place.

             

            Your use case will tell us why you want to hide the field and that may not be what you want in a report. You may want the 'white space' to disappear.

             

             

            Basically I'd say we need more information.

             

             

            Simple formulae to hide a records empty field.

             

            IsEmpty ( Self )

            • 3. Re: Hiding an object using scripts
              erolst

              But if you hide an object and the ones below it are set to slide, they will slide - so sometimes a combination of both features could be just what you need.

              • 4. Re: Hiding an object using scripts
                shauncooper

                Thanks to everyone that responded to my post, I really appreciate it.

                Mike, per your suggestion I'm providing more information with my requirements. Since I don't have the proper FM vocabulary yet to describe exactly what I need, I'll provide an example below:

                 

                Sample Report on Paintings

                Artist: Pablo Picasso

                Size: 36 x 24

                Frame Size:

                Price: $100

                 

                How I want the report layout to appear and print if Frame Size does not contain data:

                Artist: Pablo Picasso

                Size: 36 x 24

                Price: $100

                 

                1. This layout is a report layout for printing

                2. ONLY in this layout should the Frame Size label and field disappear if nothing has been entered into this field on another layout (I need this field in my other layouts)

                3. In this example Frame Size is a text entry but I have other fields with numbers and objects where I would like the same thing to happen

                 

                This is what I've done

                1. Highlighted the Frame Size label and field in my report layout

                2. From the Inspector I've chosen the Data Tab, then "Hide Objects When" under Behavior, then clicked on the pencil and have been taken to the Specifiy Calculation window

                3. At this point I'm supposed to use a script that says when no information has been entered into the selected field, make the selected label and field disappear in this layout (but keep them in other layouts, even if blank)

                Is this possible, and what script do I use? What kind of specific information needs to be entered into the script once it has been chosen?

                 

                Thanks again for your help, and yes, I'd like everything to slide up. Thanks, Shaun

                • 5. Re: Hiding an object using scripts
                  Mike_Mitchell

                  You don't use a script. You use a calculation, like this:

                   

                  IsEmpty ( Frame Size )

                   

                  in the Hide Object calculation in the Inspector.

                  • 6. Re: Hiding an object using scripts
                    shauncooper

                    Hi Mike,

                     

                    Thank you, that worked! Appreciate it, Shaun