Advanced filters

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Data Access through XPath >

Advanced filters

When collections have to be filtered using variables it is necessary to use setXPath and getXPath functions and NOT the angle brackets.

The following is the correct syntax for the Xpath expression using variables:

 

To obtain values, use the syntax: Me.getXPath("xpath[filter " + variable +"]")

 

To set values, use the syntax: Me.setXPath("xpath[filter  " + variable +"]", value)

 

Me.setXPath

Suppose that you need to calculate the minimum percentage discount in the Quotation selection process.

Only quotations offering a discount higher than 10% of the total cost of the purchase will be selected.

You must declare a variable to store the calculation and then filter the collection to set only the selected records.

The expression should look like this:

 

var MinimumPercentage = <PurchaseRequest.TotalCost>* 0.1

 

Me.setXPath("PurchaseRequest.Quotations[QuotationDiscount > "+ MinimumPercentage +" ].Selected", true)

 

 

Me.getXPath

Select all the suppliers where no discount or a discount less than the 10% of the total cost of the purchase was given.

First declare a variable to store the calculation and then filter the collection to retrieve the records.

The expression should look like this:

 

var MinimumPercentage = <PurchaseRequest.TotalCost>* 0.1

 

var BadSuppliers = Me.geXPath("PurchaseRequest.Quotation[Discount != true OR QuotationDiscount < "+ MinimumPercentage +"]")

 

 

Understanding xpath2