Jump to content

Hide Empty Portal


MikeKD

This topic is 2457 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi Folks,

I'm sure this should be quite easy, but I just can't get it to work!

I have a portal that gives the results of a search. I'm using PatternCount and filtering in the portal itself rather than using a relationship - this means I've got more control of the filtering.

I would like to hide the portal if no records come up so I can reveal a create new button. (This is for an iPad so there's not much room on the screen)

How do I do that please?!

Many thanks!

Mike

Link to comment
Share on other sites

Please provide more details about your setup. How exactly is the relationship defined, and what exactly is your filtering expression?

---
A semantic note:

40 minutes ago, MikeKD said:

I have a portal that gives the results of a search.

There is no such thing. A portal shows related records. The result of a search is a found set.

 

Link to comment
Share on other sites

 

Hi comment,

Many thanks for replying - sorry to be unclear again..

the filtering expression is:

PatternCount ( Client_for_ShiftMenu::First Name ; Shift::gFirstName )
or
PatternCount ( Client_for_ShiftMenu::Surname ; Shift::gSurname )
or
(
Shift::gSurname = "" and Shift::gFirstName =""
)

The relationship is through a global field in both tables set to "1" - so everything shows before the filtering expression narrows it down.

I have used a search global before to search using a relationship, but really like the PatternCount method and would prefer it if possible.

Have I covered all my areas of confusion?

Cheers!!

 

 

Link to comment
Share on other sites

This is not going to be simple - and I am afraid it might turn out to be slow too (these two often go together).

In a nutshell, portal filtering works at layout level - and you have no access to its results except by viewing them on screen.  So your plan to use the results of portal filtering in order to show or hide the portal cannot work. You will have to replicate those results using another method. And that method will have to test each and every record in the Clients (?) table for the conditions stated in your portal filtering formula. This could be done using a custom recursive function or ExecuteSQL(). Or even a script triggered by modification of one of the global fields. The simplest one to implement would probably be to add an unstored calculation field to the Clients table to do the PatternCounts, and look at the aggregate result from the context of Shift. You could also switch the portal filtering to use the same field and eliminate at least some of the duplication.

 

4 hours ago, MikeKD said:

The relationship is through a global field in both tables set to "1"

You don't really need those fields: just use the x relational operator with any two fields (or even no fields at all).

 

Edited by comment
Link to comment
Share on other sites

2 hours ago, comment said:

portal filtering works at layout level - and you have no access to its results

Come to think of it, that's not entirely true. Suppose you add a field that cannot be empty (such as ClientID) into the portal and give it an object name. You could then use the GetLayoutObjectAttribute() function to get the object's content - and hide the portal when it's empty. 

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thanks loads, comment.

Sorry to take so long to reply - I'm on holiday with the family, and writing this database for my wife as light relief from drinking beer and swimming!

I'll see if I can make that work - it's not something I've tried before. Very cunning though!! :-)

Cheers,

Mike

On 21/07/2017 at 8:33 PM, comment said:

You don't really need those fields: just use the x relational operator with any two fields (or even no fields at all).

Of course - that makes lots of sense!

Link to comment
Share on other sites

I don't know if it would help anyone, but it's taken me a little while to work out how to use GetLayoutObjectAttribute - it didn't come up in my FileMaker book :-/

Here's the expression that worked. PKinPickClientPortal is the object name of the pk field in the portal.

GetLayoutObjectAttribute ( "PKinPickClientPortal" ; "content" ) =""

Many thanks comment!!!

Link to comment
Share on other sites

Hi Mike, you can also just wrap it with IsEmpty() which is what I suggest you do.  Using =" " isn't the best choice.  So try:

IsEmpty ( GetLayoutObjectAttribute ( "PKinPickClientPortal" ; "content" ) )

 

Edited by LaRetta
Link to comment
Share on other sites

Hi LaRetta,

thanks for your advice. Forgive the newbie questions, but:

1. why is ="" not a good choice?

2. in your  improved calculation, do I just add a "not" in front to change it for the alternative object to appear?

Thanks so much - without yours and comments help (+ some other amazing people previously), I hate to imagine exactly how incompetent I'd be now...

Best wishes,

Mike

 

Link to comment
Share on other sites

Hi Mike,

  1. IsEmpty() was designed for this purpose so we use it.  It is also more clear.
  2. IsEmpty() is a boolean test so yes, adding a 'not' at the beginning would reverse the result.

Without the help of others on this forum, I can't imagine how less competent I would be as well!   :-)

2 hours ago, MikeKD said:

Forgive the newbie questions...

Nope, I will not.  Asking questions is a wonderful trait.

Link to comment
Share on other sites

This topic is 2457 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.