Can agent queries have if statements?

Is it possible to write and if statement in an agent query? Ex., “if($qOrg(qOrg(agent).icontains($Organization)”? If aOrg has a value then the search parameters would be past. If it does not, then this parameter would be ignored.

I tried this: $Prototype=="pRanking"&if($qOrg!=""){$qOrg(agent).icontains($Organization)}&$Rank>=0, but it does not work, nothing is returned.

if() is not used in an agent query as it is just a wrapper for … a query. Just use an & or | join around the enclosed term:

$Prototype=="pRanking"& $qOrg!="" & $qOrg(agent).icontains($Organization)&$Rank>=0

Ok. I understand the & and |. I was hoping the query could be dynamic based on if an attribute held a value or not. Not to worry, I can do this through action code.

Mark Anderson is right, and you can adjust the query dynamically!

My interpretation of the intent of your first cut was

The prototype is "pRanking"
    AND (either the note or the agent's qOrg contains $Organization)
    AND $Rank if >=0

The first clause and the third clause are trivial. The second, you wrote as

if($qOrg!=""){$qOrg(agent).icontains($Organization)}

This is equivalent to saying

( ($qOrg!="")  & $qOrg(agent).icontains($Organization)

If $qOrg is empty, the first clause is false and we are done. If not, we evaluate the test in the second clause above.

1 Like

It is a nuance…if the first argument is empty I don’t wan the query to be done, I just want this argument skipped. But, I don’t want it to be and this or that. I understand your point, though. Thanks.

1 Like

if the first argument is empty I don’t want the query to be done,

But this is exactly what Tinderbox does! If you have two clauses A & B, Tinderbox first evaluates the A clause. If it is false, it does not evaluate the B clause because it knows the result will be false.

Similarly, if you have A | B, if the first clause evaluates to true, then Tinderbox knows the result will be true and does not evaluate the B clause.

2 Likes

I’m not sure if this helps with conditional joins: Conditional statements using multiple arguments

If not I’m more than ready to accept better /fuller explanations. :slight_smile:

1 Like

Thanks, guys. This helps a ton.

1 Like