Step 5 – Filtering the portals

We need to be able to filter the portals so we have to add some fields for that purpose.

Now you’re going to add the relevant filter to each of the panels and position it above the portal.

You’re going to do several things with these ‘filter fields’.  First of all, you are going to name them, because the Portal Filter script won’t work if you don’t and then you are going to apply an OnObjectModify script trigger to the field.

You then need to set up the portal filtering which is done in portal setup

.

Below are the actual portal filter calculations. You should be able to copy and paste them into the relevant portals.

Let ([ filterField = _Home::G_CompanyFilter ]; ( PatternCount ( H_Companies::Name;filterfield ) > 0) and not IsEmpty ( filterField ) or IsEmpty ( filterField ) )

Let ([ filterField = _Home::G_PeopleFilter ]; ( PatternCount ( H_People::c_Name;filterfield ) > 0) and not IsEmpty ( filterField ) or IsEmpty ( filterField ) )

Let ([ filterField = _Home::G_Productfilter ]; ( PatternCount ( H_Products::Concat;filterfield ) > 0) and not IsEmpty ( filterField ) or IsEmpty ( filterField ) )

Let ([ filterField = _Home::G_invoiceFilter ]; ( PatternCount ( H_Invoices::Concat;filterfield ) > 0) and not IsEmpty ( filterField ) or IsEmpty ( filterField ) )

In the case of Invoices, there is a calculation field called concat which joins the Invoice # and the Client name together.

Now let’s take a quick look at the portal filter in operation

There are two things that you now have to do to each portal.  The first is to apply conditional formatting to the field so that when you select (click on) it, that row is reversed out to give the user a visual indicator as to which record they are looking at/working on.

You should do this part first as once you have set the field as a button, it becomes a grouped object nd it is sometimes difficult to select it (as a field) so you can apply the conditional formatting to it.

The second thing is to set the value of the relevant global field with the primary key of the clicked on record. (There is a script called Set_Globals that you should use)

You now need to add 4 new relationships.

You’re almost finished with this part.  All you have to do now is add some fields from the relationships that you just added.

The SetGlobals script is where you set the fields.

So when you click on a portal record, it sets the global field with that records primary key and immediately displays all of the information on that company

You should also apply a HideObjectWhen condition to all those fields so that when no company is selected, nothing shows.

Take a break now; you deserve it.  We’ve covered a lot of ground but it’s about to get interesting.