orCondition



Function: orCondition()

Returns an empty OR Pipe Filter Clause object which can be populated with Pipe Filter Conditions to build up a dynamic (script-defined) Pipe Filter. The Pipe Filter can then be used to fetch data from a Pipe.

Note that only one element within an orCondition() must return true in order for the orCondition() to return true when used as part of a Pipe Filter Condition.

Syntax

orCondition()

Examples

do ( 
	// First build up the filter
	$filter = orCondition(), 
	$filter = addElement($filter, fieldCondition("productId", _EQUALS, in.productId) ), 
	$filter = addElement($filter, fieldCondition("productStatus", _EQUALS, "OK" ), 
	
	// set the filter on the Pipe 
	setFilter( prodLookup, $filter ), 

	// now lookup on the pipe lookup (prodLookup), 
	$prodName = prodLookup.name
)

This example creates an OR clause which specifies that the Attribute productID must equal the value currently held in in.productId OR the productStatus Attribute in the target Pipe must equal "OK". The filter is then assigned to the Pipe prodLookup and a lookup is performed by invoking the lookup() function.

Note that you can add as many Pipe Filter Conditions as you need to the OR Pipe Filter Clause.


Nested Example

do(
	$filter = orCondition(), 
	$filter = addElement($filter, fieldCondition("productId", _EQUALS, in.productId) ), 
	$filter = addElement($filter, fieldCondition("productStatus", _EQUALS, "OK" ), 
	$filter = addElement($filter, fieldCondition("productClass", _EQUALS, "RETAIL" ), 
	...
)

Clauses can also be nested:
do(
	$statusCond = orCondition(), 
	$statusCond = addElement($statusCond, fieldCondition("productStatus", _EQUALS, "OK" ), 
	$statusCond = addElement($statusCond, fieldCondition("productStatus", _EQUALS, "GOOD" ), 
	$filter = orCondition(), 
	$filter = addElement($filter, fieldCondition("productId", _EQUALS, in.productId) ), 
	$filter = addElement($filter, $statusCond), 
	...
)


See Also