All product information in wiki.bizagi.com is only valid for Bizagi BPM Suite 9.1.X.
For newer Bizagi BPM Suite versions (10.X and up) please visit the User Guide.
 

Filter

From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS

Jump to: navigation, search

<keywords content="keywords"> filter, filter xpath, filter function</keywords> 


Contents

How to Filter Information

A filter indicates one or more conditions to be met within a 1:N relationship. Filters are used in rules to evaluate certain records of a Collection.


The structure of a filter uses XPath, and it is constructed as follows:

<MainProcessEntity...NameOfTheNEntity[AttributeName= value]>


The following can be used as operators:


Operator

Name

Example

=

Equal to Comparative

<Request.LoanRequest[LoanType.Type ='CreditCard']>

!=

Not

<Request.LoanReq[LoanType.Type!= 'AssistCard']>

>

Greater than

<Request.LoanReq[ValueRequested > 1000]>

<

Less than

<Request.Loan Req[ValueRequested < 1000]>

>=

Greater than or equal to

<Request.LoanReq[ValueRequested >= 1000]>

<=

Less than or equal to

<Request.LoanReq[ValueRequested <= 1000]>

AND

AND

<Request.LoanReq[(ValueRequested > 1000 AND LoanType.Type! = 'Credit')]>

OR

OR

<Request.LoanReq[(ValueRequested < 1000 OR Term > 6)]>


True

<Request.LoanReqi[LoanType.RequiresDisbursement]>


!

false

<Request.LoanReq[!LoanType.RequireDisbursement]>


Example: If a Loan Request in our data model can have one or more loans requested, get the following information in accordance with the data model presented.



Image:Business_Rules3_Image006.jpg


Image:Bulletazul.gif With XPath, we can get the entire collection of loans requested whose value requested is over 50 million as follows

<idRequest. Request_LoanReq[cValueRequested > 50000000]>;


Image:Bulletazul.gif To get the entire collection of Values Requested of the loans whose value is over 50 million,

<idRequest.Request_LoanReq[cValueRequested > 50000000].cValueRequested>


Image:Bulletazul.gif To get the entire collection of ids of the loan types whose Value Requested is over 50 million and less than 12 installments:

<idRequest.Request_LoanReq[(cValueRequested > 50000000 And iTerm < 12].idLoanType.id>


Image:Bulletazul.gif To get the values of the loans that Require Disbursement:

<idRequest.Request_LoanReq[bRequireDisbursement].cValueRequested>


Image:Bulletazul.gif To get the values of the loans that DO NOT Require Disbursement:

<idRequest.Request_LoanReq[!bRequireDisbursement].cValueRequested>


Image:Bulletazul.gif To get the entire collection of Loan Categories of the loans requested whose value is over 50 million:

<idRequest.Request_LoanReq[cValueRequested> 50000000].idLoanType.idLoanCategory.sLoanCategory>


How to Filter Information Using Variables

A filter can also use variables to compare with.

Me.getXPath("MainProcessEntity...NameOfTheNEntity[AttributeName= "+ variable +"]")


The following operators can be used:


Operator

Name

Example

=

Equal to Comparative

If x is a variable that has a value previously assigned.

Me.getXPath(“Request.LoanReqi[LoanType.Type = ” + x + “] .cValueRequested”);


!=

Not

If x is a variable that has a value previously assigned.

Me.getXPath(“Request.LoanReq[Term != ” + x + “] ”);

Greater than

If x is a variable that has a value previously assigned.

Me.getXPath(“Request.LoanReq[Term ≥ ” + x + “] ”);

Less than

If x is a variable that has a value previously assigned.

Me.getXPath(“Request.LoanReq[Term ≤ ” + x + “] ”);

>=

Greater than or equal to

If x is a variable that has a value previously assigned.

Me.getXPath("Request.LoanReq[ValueRequested >= ” + x + “] ”);

<=

Less than or equal to

If x is a variable that has a value previously assigned.

Me.getXPath(“Request.LoanReq[ValueRequested <= ” + x + “] ”);

And

AND

If x and z are variables that have values previously assigned.

Me.getXPath(“Request.LoanReq[ValueRequested ≤= ” + x + “ AND Term < “ + z + “] ”);

Or

OR

If x and z are variables that have values previously assigned.

Me.getXPath(“Request.LoanReq[ValueRequested ≤= ” + x + “ OR Term < “ + z + “] ”);


Example: If a Loan Request in our data model can have one or more loans requested, get the following information in accordance with the data model presented.


Image:Business_Rules3_Image007.jpg


Image:Bulletazul.gif Using XPath, we can get the entire collection of loans requested whose value requested is greater than the Client’s pre-approved value, as follows:

var Value= <idRequest.cPre-approvedValue>;

Me.getXPath(“idRequest. Request_LoanReq[cValueRequested > “ + Value+ “]”)


Image:Bulletazul.gif To get the entire collection of Values Requested of the loans whose value is greater than the Client’s pre-approved value:

var Value= <idRequest.cPre-approvedValue>;

Me.getXPath (“idRequest. Request_LoanReq[cValueRequested > “ + Value+ “].cValueRequested”)


Image:Bulletazul.gif To get the entire collection of Loan Categories of the loans requested whose value is greater than the Pre-approved Value:

var Value= <idRequest.cPre-approvedValue>;


Me.getXPath(“idRequest.Request_LoanReq[cValueRequested > “ + Value+ “].idLoanType.idLoanCategory.sLoanCategory”)


How to filter a Table (or Grid)

Records to be displayed on the grid can be filtered to show only specific values depending on a given condition.

In a Credit Request process a filter in a table is needed to show all products different from 'Assist Card', that have been Approved by the Risk Office and have a certain state in the process.



The process has a 1:N relationship between the Request and the Products entity.

  • The approval of the Risk Office is set in the boolean-type attribute called Approved
  • The process state is set in the Product entity, in an attribute called ProductState
  • The type of Product (Assist Card, Credit Card, Credit) is saved in an attribute called ProductType.



The filter is created using the Forms Designer, where the table is built.

1. Select the grid where the filter will be created. Then go to the Related Entity Option in the Properties box, and select Filter



2. A new window is opened. Create the conditions to filter:

When the condition is to select a record of a Parametric entity, Bizagi will show all the entries to select one.






If the attribute to evaluate is boolean, Bizagi will display the True or False option



The values show for the Parametric filters, are the ids of the records, saved in Bizagi.

The user can choose between two options:

  • Filter to show all the records that match with ALL the conditions
  • Filter to show all the records that match ANY of the conditions


Click on OK when the filter is finished and SAVE the Form



The grid would be filtered, and it will show only the records that apply to the filter





How to update records of a collection based on a date

In some cases you might need to update records of a collection based on a specific date. For those cases you need to establish the date for which the records will be filtered and the new value of the field to update in the filtered records.

Suppose you need to update the status of the Production Orders that were created in 3/05/2012 to “Dispatched”. You should be able to select the date to the records to be filtered, in the activity form, and the new value for the production order status, in this case “Dispatched”

For doing it, you must define an expression that goes through the records of the collection and compares the creation date with the date established to filter the records. Once a match is found, the target field, in this case the “Status”, is updated to the value selected for the new status. For this example we used a button to execute the business rule.

This would be the status of the orders before they are updated based on its creation dates:

This is the status of the production orders once they have been updated.

The expression has the following structure:

First we obtain the date by which the records will be filtered, then we search for the records that match with such date and finally the records are updated.

To obtain the date simply store the value of the date field in a variable. Do the same for the field to be updated.

var DatetoCompare=<UpdateOrders.Datetofilter> 
var NewStatus=<UpdateOrders.Statustoupdate>

Go through the records by using an Iterate over Xpath. In this case we use the ProductionOrder variable to go through the records.

For more information about Iterate over xpath please refer to http://wiki.bizagi.com/en/index.php?title=Iterate_over_Fact_or_XPath

To compare the dates of the records and the specified date to filter the records obtain the desired date of each record in a variable and use an “If condition” to update them.

var CreationDate=ProductionOrder.getXPath("CreationDate") 
if (CreationDate==DatetoCompare) 
{ 
ProductionOrder.setXPath("Status",NewStatus) 
}


How To Filter a Combo

It is possible to filter the information that is shown in the Combo (drop down list), by entering a condition in the Form  in the property Filter.

For example, in an Invoice Payment process the Invoice Payment Option combo must be filtered. This is necessary depending on the payment situation: if the product or service provider does not accept Credit Card payments, the combo that shows the Payment Options should be filtered.


The Payment Options information is stored in a Parameter Entity.



The options are: Bank Transfer, Credit Card and Check.

The Invoice Payment process determines if the provider accepts Credit Card payments, or not.. 

The Payment Option can be chosen previously, and in this case it could be Bank Transfer.


The process waits for the reception of the invoice in the Receive Invoice event. The filter is created using the Forms Designer in the event form.

It is possible to receive many invoices, so the information of the invoice resides in a Collection (grid) on the form.

To create the filter follow these steps :


1. Click the Open Add Form option to edit the combo of the Payment options.



2. Select the Payment Options combo



3. Go to Properties in the left panel.



4. Select the Filter property and click the button.


5. The user can choose between two options:

     Filter to show all the records that match with ALL the conditions
     Filter to show all the records that match ANY of the conditions





6. Click the Add Filter Condition button.


7 .The combo can be filtered by the values that reside in the parametric entity. The attributes in this case are Code and Payment Option. Select the Code attribute.





8. In the Operator select the “Is Different To” option





9. In the “Insert An Argument” option, there are several options :

  • Set null value : to filter the null values of the entity.
  • Set constant value : to filter by a constant value of the attribute.
  • Choose an attribute : To select an attribute from the same entity
  • Evaluate Data binding : to select a value from another entity in the same context.

Select the Set a Constant Value and enter the “CC” option.



The CC is the value of the attribute for Credit Card option, so at the end the combo it will show only the values that are different from Credit Card.



In the web application, the Combo will appear like this :



  <comments />