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.
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?
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.
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.
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
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?
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.)
1 of 1 people found this helpful
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.
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.
"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.