Finding Union Of two queries Query Business rule

Francis16
Tera Contributor

Hi, We have a requirement on Query Business rule.

Lets say i have a table 'TABLE'  with reference field A. Also lets say, A would refer to records X and Y. Now our requirement is to run a query business rule on 'TABLE' that returns all the records where A is X. And for the records where A is Y, we need to add a query. In simple terms we need (unqueried (A=X)) UNION (queried (A=Y)).

Thanks in advance

1 ACCEPTED SOLUTION

palanikumar
Giga Sage

Hi,

I think you are trying something like this

(A==X) or (A==Y and B==Z)

Field A can be X. If field A is Y then field B should be Z.

There is no direct encoded query for the above. So, I'm applying math here. The above condition can be converted to this

(A==X or A==Y) and (A==X or B==Z)

So, you can try below encoded query

A=X^ORA=Y^A=X^ORB=Z

Thank you,

Palani

Thank you,
Palani

View solution in original post

2 REPLIES 2

palanikumar
Giga Sage

Hi,

I think you are trying something like this

(A==X) or (A==Y and B==Z)

Field A can be X. If field A is Y then field B should be Z.

There is no direct encoded query for the above. So, I'm applying math here. The above condition can be converted to this

(A==X or A==Y) and (A==X or B==Z)

So, you can try below encoded query

A=X^ORA=Y^A=X^ORB=Z

Thank you,

Palani

Thank you,
Palani

Hi,

This works. I used something like

q=current.addQuery('A',"!=",'X')

q.addOrCondition('A','=','X').addCondition('B','Z');

 

Thanks.