look the image where I simulate a possible solution:
1) Portal e button ( I change the $$dGTLR with global field value:
2) Portal details:
3) script details:
Set Error Capture [ On ]
Allow User Abort [ Off ]
Set Variable [ $$dGTLR; Value:Parent::Global ]
Refresh Portal [ Object Name: "Portal1" ]
4) Browse mode with all portal row
5) Browse mode with $$dGTRL = 1
6) browse mode with $$dGTRL = 0
You can simply write:
EDIT: actually, just use
as your portal filter. The variable's value is itself regarded as either True or False, so no need to evaluate it again.
Your filter calculation doesn't make sense; because it make no reference to any of the related data of the child records.
A portal filter calc is performed across every child record that the basic relationship includes.
Let's say we have a Suppliers table; and a Products table.
And a relation from Suppliers to Products where pkSupplierID = fkSupplierID
We are on the Acme Plumbing supplier record.
There are 971 Acme products.
We could create a filter calc Products::TYPE = $$type
And enter "faucets" in $$type
And now we would only see the Acme products where Type = "faucet"
It makes sense if you want to achieve a “now you see them (all), now you don't” toggle … (the question is if that makes sense by itself).
The calculation references no child data and therefore does nothing.
The calculation references no child data …
That simply means that that calculation filters without regarding any child data …
… and therefore does nothing.
… but that doesn't mean it doesn't filter.
Create a variable $$display and filter a portal by just that expression; if $$display is False, you won't see any portal rows.
Sorry, yes, you're right, for all or nothing filtering, a global variable with true or false value by itself does work. It doesn't show just one record though, as claimed at the top of the thread.
Thanks for all your suggestions guys.
I think I'm more confused than ever! Maybe I have misstated my intention.
What I need is not a toggle to show either all records or no records but a calculation that I use in my portal filter that will show one record or all records.
If the global variable is True then I want it to show a particular record in the portal based on another variable. For example
IF ($$dGTLR = 1;ProductID=$pID;"")
I can get that part of it to work but in the same calculation I need it to show all records if $$dGTLR =0 (or not equal to 1 at least)
Where is $pID set and what is the purpose of setting it?
Note that if you're using it for a portal filter, $pID will need to be a global variable $$pID.
Script variables ($pID) "evaporate" at the end of the script.
But if you want the filtering to occur only while a script is running, then in fact a script variable would be the right choice.
Maybe you should, for the moment, stop mentioning the calculations and instead describe what you are trying to do.
What is the user doing?
Agreed $pID will need to be global $$pID as it is captured in a script a couple of scripts back.
Continuing the products example, the user will be selecting a product in a popover portal. (Lets call it Popover1/Portal1). At that point the productID, $$pID, is captured.
When the user hits "Select", the $$pID is set, this popover is closed and another popover is opened. This popover has another portal. (Lets call it Popver2/Portal2) And it's this portal that I want filtered to show only the product with a ProductID=$$pID.
This behaviour needs to be controlled by the global variable $$dGTLR. If $$dGTLR is True then the above needs to happen. If $$dGTLR is FALSE then forget the portal filtering because the user won't be entering Popover1/Portal1 at all but will be going straight to Popover2/Portal2 which will need to show all records.
I can get the portal filtered when $$dGTLR is TRUE. That's all working. What I need is for the portal not to be filtered when $$dGTLR is FALSE.
Then the expression could be:
$$dGTLR = 0 OR Products::ProductID = $$pID
However; what is happening to $$pID when $$dGTLR is false?
If $$dGTLR = false does it mean that $$pID is empty?
If that were the case then it could be
IsEmpty( $$pID) OR Products::ProductID = $$pID
Yes, if $$dGTLR is false then $$pID would never get set and would therefore be empty.
I'll give that expression a go.