I think you need to describe what you want in more specific detail.
You cannot directly redefine the calculation expression used, but you can change the values referenced by that expression. In other words, your script can change the values in fields or variables referenced in that expression.
You might have this expression:
LayoutTable::GlobalNameField = PortalField::NameField
Then your button click can put different names in the GlobalNameField to get the portal to filter on different names.
You can even store the expression as a text field and then your portal filter expression might be:
Evaluate ( Table::Textfield )
so that your button click can assign a different expression to the text field in order to get a different filter expression.
I have Boolean check boxes for; Available, Covered, Dispatched, Loaded...
My employees want to see shipments sorted by these characteristics.
i used a portal in this instance because i can limit the invoices each sales person see's via a relationship. (they see only theirs)
So I'm trying to filter the portal by the above criteria... If invoice::INCovered =1 sort by covered
sort by or select by?
If Invoice::INCovered = 1 do you only want to see related records in the portal where this field has the value 1?
I don't know the context of the layout where you have placed your portal. I'll refer to the layout's table occurrence (which is named in Layout setup in the "show records from" drop down), to be "LayoutTO".
So if you have this relationship:
LayoutTO::anyField X Invoices::anyfield
An unfiltered portal to Invoices will display all records from the invoices table. Other relationships can be used here, this is just to get things started.
Then this portal filter can work off of boolean check box fields defined in the Layout's table:
If ( LayoutTo::Available ; Invoices::INAvaliable ) or
If ( LayoutTO::Covered ; Invoices::INCovered ) or
If ( LayoutTO::Dispatched ; Invoices::INDispatched ) or
If ( LayoutTO::Loaded ; INvoices::INLoaded )
I'd experiment with this basic approach. You may find that you don't need the If functions and can just use:
Invoices::INAvaliable or Invoices::INCovered or Invoices::INDispatched...
Thats actually a great idea. I can use that else where to clean up a few things.
But note that you may have issues getting the portal to update after you change the values in one of the checkboxes in the related table.
You can use Refresh WIndow [Flush cached joine results]
or you can include each of the layout fields referenced in the portal filter as a match field in the relationship using the X operator and the portal will update without the added script.