Jump to content

Recommended Posts

Good morning.

I am trying to setup a portal for viewing products where there are a number of conditions by which I view this portal. This includes a keyword search and filtering by other criteria. The snippet below with the keyword search (second line), and the PatternCount() in the fourth line work fine, but the bit I am not getting to work is parsing the third line (in bold).  The content of this line needs to be dynamic - so a field or variable that I point to.
I know that if I put the actual condition text there (or True) it works fine, but not coming from a field or variable.  I am assuming that this should be possible.
Is there some other way to format this line (escaped characters for example,) because I'm parsing it incorrectly? 

If (
IsEmpty (User::g_SearchProducts) ;
User::t_Portal_Filter_By_Calc ;
PatternCount(Standalone_Code::Code&Standalone_Code::Description&Standalone_Code::Comments; User::g_SearchProducts) > 0
)

What am I doing wrong here please?
Greg

Link to post
Share on other sites
3 minutes ago, Greg Hains said:

The content of this line needs to be dynamic

Not sure what exactly that means. If you want the user to enter a formula that evaluates to true or false, then you need to apply the Evaluate() function to the user entry. And the user must be proficient in Filemaker's calculation syntax. 

 

Link to post
Share on other sites

Hi Comment.

Thanks for responding.
The formula when "hard coded" in works fine, so use place the formula within Evaluate()
I'll try that - thank you.
Greg

Link to post
Share on other sites

Hi Comment,

I think I've misunderstood how that function works - I've checked the FM Help pages.

If the text field that contains the text calculation I want to parse to the script reads "Product::QtyOnHand = 0" (without the quotes), when I Evaluate() it, the result is 1 - not literal text as I would like.  How do I get the literal text out of that field and into the portal filter calculation please?

Greg
 

Link to post
Share on other sites

I am not sure we are on the same page here. What would be the point of getting "the literal text out of that field and into the portal filter calculation"? That's exactly what your original calculation does - and your filter calculation will return False when evaluating this text, as it will with any text that does not contain any digits other than 0. If you want the filtering expression to look at the text in that field as a formula, you must tell it to evaluate it as a formula.

I am also puzzled how a field from the Product TO can help in filtering a portal that apparently shows records from a TO named Standalone_Code.

 

Link to post
Share on other sites

Hi Comment.

I have a single Products table.  Three of the fields in there are:
    Product Code (text), Description (text), and QtyOnHand (numeric).

I also have a keyword search tool there - you can see from the PatternCount() command also there. I can display the various views, filters and keyword search results based on the same portal duplicated many times where the non "selected" ones are hidden but the portal filter command is straight forward but that is messy and not terribly smart.  I figure that if I can parse all the smarts to the portal filter command then I can pretty much use the one command, thus being able to use a single portal to display a filtered view and keyword search results in the one - rather than having multiple portals all configured slightly differently and then hiding the ones I don't wish to view - messy and not smart.

I thought that if I could parse the text contents of that field "t_Portal_Filter_By_Calc" into the command then it should work, but Evaluate attempts to turn that command of "Product::QtyOnHand = 0" into a number (resulting in zero) therefore it fails.

I'm not sure I explained myself very well the first time. 
Thank you again for your help.

Greg

Link to post
Share on other sites
5 minutes ago, Greg Hains said:

Evaluate attempts to turn that command of "Product::QtyOnHand = 0" into a number (resulting in zero)

Not exactly. Evaluate ( "Product::QtyOnHand = 0)  attempts to return a Boolean result - that is either 1 or 0 - depending on whether the comparison is true or false. I think that's what you would want with an expression like that. To show records with no QtyOnHand and filter out all others. If you want something else, then please explain further - preferably in simple terms.

 

 

Link to post
Share on other sites

Hi Comment.

The field with the command (fragment) for the filter portal is: t_Portal_Filter_By_Calc
Which could contain text such as:
   "Product::QtyOnHand = 0"   or   "Product::QtyOnHand > 0"
and then using that field in the portal filter command.

Greg

 

 

Link to post
Share on other sites

Hi Comment.

Problem fixed.
I had applied the correct method all along, but there was a typo (doesn't matter how big or small though, does it?!) that had broken another part of the relationship. All working again.

Thank you for your expertise once again. Ticket closed. :) 
Greg

Link to post
Share on other sites
2 hours ago, Greg Hains said:

I had applied the correct method all along

I don't think so. Your original calculation cannot work the way you intend.

 

Link to post
Share on other sites

Hi Comment,

The error I made was refreshing the wrong portal name so the results never showed. 
 

Link to post
Share on other sites

Nevertheless, your original calculation cannot work the way you intend. I am stressing this point for the benefit of other users that might be reading this in search for a solution to a similar problem. If you want to have a formula in a field, you must use the Evaluate() function in order to force the calculation engine to evaluate it as an expression. Otherwise it will be evaluated as meaningless literal text.

 

Link to post
Share on other sites

Comment,

Perhaps I should have posted more information at the time - such as screen shots and maybe the file itself. My apologies if I muddied the waters at all.
The solution you provided worked exactly how I wanted, but the error was mine in that I was not addressing the portals correctly. You still helped me resolve it.

Greg 

Link to post
Share on other sites

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.