10 Replies Latest reply on Jun 29, 2016 9:35 AM by BruceRobertson

    Hide Object When with multiple fields

    hanabi

      I have an object that needs to be hidden when a two fields return specific results.

       

      For example: I have a book named Book 1 (in a list of various books), and when the Book Name field says "Book 1" and the Status field says "Checked Out," this object should disappear.

       

      I have tried entering the following into the "Hide Object When" field, but it is not functioning as expected.:

      (Book List::Book Name = "Book 1" and Book List::Status = "Checked Out")

       

      It almost seems like I should have to run a script to perform a find for "Book 1" and "Checked Out" before it can return a true result and hide the object.

       

      Ideas?

        • 1. Re: Hide Object When with multiple fields
          mikebeargie

          Context matters when you are making those calculations.

           

          EG you are trying to hide an object from one table (books) based on the calculations of another table (Book List)

           

          You may want to create a calculated "status" field in the books table itself that returns a 0 or 1 for if a book is checked out, and then make your hide/show condition based on that status field.

          • 2. Re: Hide Object When with multiple fields
            hanabi

            This causes it to be hidden if ANY book's status becomes "Checked Out." Because there are many different books that can be marked as Checked Out at any time, it can't differentiate. Other than creating a calcStatus field with a unique calculation for each book title, any suggestions?

            • 3. Re: Hide Object When with multiple fields
              hanabi

              P.S. I am working in a list view of one table, rather than different table referencing the same information. I have an individual record layout if I need details on who checked it out and when, but I'm trying to keep a simple user view. (The object I'm trying to hide is a "Check Out" button which disappears when the script it runs marks Book 1 as checked out.)

               

              I'm not sure if that makes what I am trying to do more simple or more complicated.

              • 4. Re: Hide Object When with multiple fields
                mikebeargie

                That makes sense if you understand my last reply. You are trying to hide an object in one table, using the context of another table.

                 

                You can make a more robust calculation to force the context into the books table, or you can create a status field in the books table to evaluate against.

                 

                I'm not sure what the relationship from Books to Book List is, so I can't advise, and it appears that you may be relating the two tables based on book name instead of book id.

                 

                A robust calc evaluating without context would look like:

                ExecuteSQL("SELECT COUNT(*) FROM \"Book List\" WHERE \"Book Name\" = ? AND Status = ?";"";""; Books::Book Name ; "Checked Out") > 0

                If you were on the Books table, that would use the context of the current record's Book Name (underlined) to determine the status from the other table. This would evaluate to True and hide an object if the count of those records that matched was > 0.

                • 5. Re: Hide Object When with multiple fields
                  PeterDoern

                  Am I understanding correctly that this list of books would be like:

                   

                  record 1: Book 1

                  record 2: Book 2

                  record 3: Book 3

                  .

                  .

                  .

                  record n: Book n

                   

                  and that you have a Check Out button on each row or in the header that will run a script that checks out the book in the current record,

                   

                  and that you want the Check Out button to disappear when the book Status = "Checked Out"?

                   

                  If so, then the only condition you need in your Hide calculation is: Book::Status = "Checked Out"

                   

                  If not, then my apologies

                  • 6. Re: Hide Object When with multiple fields
                    mikebeargie

                    I’m confused here as well, what’s the difference between “Books” and “Book List”

                     

                    Is the latter just a table occurrence or the name of the layout?

                    • 7. Re: Hide Object When with multiple fields
                      hanabi

                      AH! Rather than having the object in-line with my list view, I had it outside of the line items and was trying to do something crazy. Now that it is in-line, It really is as simple as Hide Object When "Book List::Status="Checked Out," provided my button is in line.

                       

                      However, my script is now changing the status of ALL books to Checked Out.

                       

                      (And yes, I just have a single table occurrence named Books, and the layout is Book List. So "Book List::Status" is the Status field on my Book List layout, within the single Books table occurrence.)

                      • 8. Re: Hide Object When with multiple fields
                        robertwoods

                        Hello

                         

                        I think your original idea would work with more brackets. Try :-

                         

                        (Book List::Book Name = "Book 1") and (Book List::Status = "Checked Out")

                         

                        Your original code said the following, as far as FileMaker was concerned....

                         

                        (Book List::Book Name) = ("Book 1" and (Book List::Status = "Checked Out") ), and this would always fail since the part after the first equal sign would never equal the book name.

                        1 of 1 people found this helpful
                        • 9. Re: Hide Object When with multiple fields
                          hanabi

                          I had tried lots of variations of the ( )s, and none of them had worked. With Filemaker, it's often just better to say "what is the simplest way I can accomplish this?"

                           

                          I moved my object to the line-item and had it freeze the window, go to the related record, change the status, and then return to the layout.

                          • 10. Re: Hide Object When with multiple fields
                            BruceRobertson

                            "I had tried lots of variations of the ( )s, and none of them had worked."

                            Randomly throwing parentheses at an expression won't work.

                            They CAN be applied correctly; as RobertWoods describes.