Yes you can, but it's not clear exactly what you have set up nor exactly what you want to have happen here so it's a bit tough to provide specifics.
One new and useful trick is to assign a portal an object name and use Refresh Portal to refresh a given portal in order to get changed filter criteria to produce an updated list of records in the portal.
I have a portal of Tasks from a separate table in a layout. Some of the tasks are completed and some are uncompleted. The demarcation of completed vs uncompleted is a field in the Tasks table that exists in the portal called "completed" that has a Yes/No radio button. "Yes" marks completed.
I would like a toggle button to go between showing ALL tasks and only UNCOMPLETED tasks.
I know the object name and refresh script. My quandary is how to script it into ONE toggle button.
I could do 1 button that makes the filter ::completed = "No" [ie. Uncompleted tasks], and a separate button that makes the filter ::completed = "Yes" or :: completed = "No", BUT that would be 2 separate buttons.
Is there a way that the above can be combined into only 1 button? Ie. A toggle button back and forth.
I do this with a checkbox (number). When checked the value is 1. Then your filter is a case() to test for checked (1) or not.
Sent from miPhone
I could do that with "Yes" and ALL (ie. Your example, 1 and all). HOW do I do that? What is the scripting?
What is your current filter with "yes"? can you post the calculation? are you triggering a script? Post what you have and we can help your revise it.
something like this Filter:
checkboxfields = "yes" ; Tasks = "Completed ; Tasks = "Uncompleted"
Your portal filter formula could become:
$$Selected = "Uncompleted" ; Tasks::completed = "No" ;
not IsEmpty ( Tasks::completed )
The script on the button would do something like:
If $$Selected = "Uncompleted"
Set Variable [ $$Selected ]
Set Variable [ $$Selected ; value: "Uncompleted" ]
Refresh Portal [ "PortalName" ]
Your first button click would set a global variable to "Uncompleted", so only uncompleted tasks would be shown. Your second click would clear the variable, so any task marked Yes or No would be shown.
I'm confused. I've literally laid out the entire portal in detail, twice. I do not want to do additional checkboxes, that would defeat the purpose. I already, as mentioned, has a radio button on each row with a "Yes" or "No" for completed for the task. This gives either a "Yes" or a "No" for the given task for completed.
As of now, I have no script other than the standard related record filter that is applied to a portal.
I am trying to come up for a script for a button. I listed, above, what I could do for 2 buttons.
Maybe the answer is "case", but the problem is I need to include "Yes" in both filters, so that seems to complicate the ability to do the Case, I believe.
if you are calling a script, you can pass a variable to the script (from the button).
But the filter must rely on a value to make the change. I proposed setting a field. If you do not want to create another field, then use the method of setting a $$variable, as outlined by dtcgnet, above.
I prefer NOT to use the variables like this, as there is not an easy way to control the value in different records.
If you need to show ALL in the portal and "toggle" to Completed only, your case would change to something like:
Case ( varOrField = "YES" ; related::Task = "Completed" ; not IsEmpty (related::myPrimaryKey) )
I don't understand why are you even thinking of a script.
I may just be overcomplicating things, I'm not sure.
I have Tasks shown in a portal. Some are marked "Yes" to ::completed, and some are marked "No" to ::completed. What I am essentially trying to do is have the "No" ::completed always in the portal, and the ability to hide the "Yes" ::completed, with a button. It would need to filter "Yes" & "All", back and forth.
Beverly -- I think I may have gotten confused: You weren't saying to add a checkbox to each row, you were saying to use a checkbox instead of a button. Is that correct? Thus checked = filtered only completed (ie. "Yes"), and no check = show all? Is that what I was misunderstanding?
Bruce -- I'd love not to do with a script and make it simple, I thought I need a script to filter the portal in 2 different ways, essentially?
yes, add a field outside the portal. then the calculation on the filter will update.
my example file in this article shows how the filter can change with a drop-down list and a checkbox:
Okay, I just found this thread: Dynamic Portal Filtering--->On Steroids
The sample file has an "active", "inactive", "retired" checkbox system. This may be what Beverly was referencing? I'm not quite sure. Regardless, I could definitely go with that feature instead of a toggle button. In the sample project I'm trying to understand the portal filter calculation and how it relates to the three checkbox items. Any help in deciphering would be greatly appreciated.
The Case and dynamically filtering portals, if it wasn't obvious, is slightly new to me.
Much appreciated the patience.
yes, my example is similar, but more simple.
I happen to have two fields (one to filtered by month & year, and another to just show all). the filter:
( salesperson::no_filter = 1 ; not IsEmpty ( sales::salesID ) // all related
; not IsEmpty ( salesperson::filter_date ) ; sales::year_month = salesperson::filter_date // filter by year_month
; "" // no related )
1. the checkbox "no_filter", if checked, shows all related sales for a salesperson
2. OR the dropdown "filter_date", matches the salesperson to ONLY those for the selected month & year
3. OR if the checkbox is unchecked and the filter_date is not selected, then NOTHING is show in the portal (no matches)
you don't need both ways to change the portal (filter), of course. that's why I suggested the checkbox "toggle", because it is so easy.
if you want a button, it's script step can simply change the 'toggle' (field) from 1 to 0 to 1 to ...
You don't even need the field on the layout. But the filter can be based on it. The conditional on the button (color, for example) could change based on the value set.
I suggest you create and upload a simple example file, which we can then modify to illustrate relevant points.