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.
 

Other Rules

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

Jump to: navigation, search

<keywords content="keywords"> rules, entities, 1:N relationship, instantiate, count entries, modify entries, delete entries, add entries </keywords> 

Contents

Using Entity Manager

Note: It is very important to point out that EntityManager should only be used to get and work with entities that are not related to the case and that CANNOT be accessed directly by surfing the data model with XPath. This is because EntityManager does not get the data from the Scope, but from the Database directly. Thus the information that has not be persisted yet is not going to be found by the EntityManager.


Image:Bulletrojo.gif How to Instantiate an Entity

Image:Bulletrojo.gif Get the Value of an Attribute (column) from a Table

Image:Bulletrojo.gif How to Count the Entries of a Search in an Entity

Image:Bulletrojo.gif How to Modify Information in the Entries of an Entity

Image:Bulletrojo.gif Delete Entries from an Entity

Image:Bulletrojo.gif Add Entries to an Entity


How to Instantiate an Entity

CEntityManager.GetEntity(“EntityName").GetEntityList("", "", "", "");

 

Parameter 1: Name of the Attribute to be Filtered

Parameter 2: Value of the Attribute to be Filtered

Parameter 3: Search

Parameter 4: Attribute to be used to arrange the search


Image:Bulletazul.gif If you would like to instantiate all the entries of an entity that meet just one condition:


oEntEntityNameList = CEntityManager.GetEntity("EntityName").GetEntityList("AttributeName", "<OtherAttributeRelatedPV>", "", "");


Image:Bulletazul.gif If you would like to instantiate all the entries of an entity that meet several conditions:


oEntEntityNameList = CEntityManager.GetEntity("EntityName").GetEntityList("", "", "AttributeName Operator "+<OtherAttributeRelatedPV> +" AND OtherAttributeName Operator Value ", "");


oEntEntityNameList: Variable where the entity will be instantiated.

EntityName: Name of the entity that will be instantiated.

AttributeName: Name of the Attribute for which the filter will be used.

 

OtherAttributeRelatedPV: The value that the attribute will take on, which can be an attribute or a fixed value.  In this case, it is an attribute.

OtherAttributeName: Name of the other Attribute for which the filter will be used.

Value: The value that the attribute will take on, which can be an attribute or a fixed value.  In this case, it is a fixed value.

Operator: The following can be used as operators in searches:


Operator

Name

Example

=

Equal to

idClient = <idClient>

<> 

Other than

ClientName <> 'John'

Greater than

balance > 600

Less than

balance  < 600

>=

Greater than or equal to

balance >= 600

<=

Less than or equal to

balance <= 600

AND

And

balance >= 600 AND idClient = <idClient>

OR

Or

balance = 600 OR balance = 100

BETWEEN

Between

balance BETWEEN 200 AND 500

IN ()

In

balance IN (600, 650, 700)

IS NULL

Equal to null

NameCity IS NULL

IS NOT NULL

Other than null

NameCity IS NOT NULL

 

Example:

All the entries in the WFUSER (user) entity where the idlocation is equal to the id of the location of the user who created the case  .

EntUsuarioList= CEntityManager.GetEntity("WFUSER").GetEntityList(“idLocation", Me.Case.Creator.Location.Id, "", "");


All the entries in the City entity where the idCountry is equal to the Client’s birth country and the idProductType is 1, 4 or 5. EntLoanRequestList= CEntityManager.GetEntity("City").GetEntityList("", "", "idCountry = " + <idRequest.idClient.idBirthCity.idCountry> + " AND idProductType in (1,4,5)", "");



Note:When working with string attributes their value requires single quotes when using GetEntityList.



Get the Value of an Attribute (Column) from a Table

Image:Bulletazul.gif To get the value of an attribute, indicate the row where you can find it.  In order to do so, you must:

oEntEntiyName = oEntEntityNameList[i];

oEntEntiyName.Attributes["AttributeName"].Value


Image:Bulletazul.gif To get the value of the Primary Key of the entry in which the Iteration can be found.

oEntEntiyName = oEntEntityNameList[i];

oEntEntiyName.SurrogateKeyValue


oEntEntiyName: The name of the variable used to get the row of the entity.

oEntEntityNameList: Variable where the entity was instantiated.

AttributeName: Name of the Attribute that you would like to find.

i: Row number.

If the value is from a Parameter entity please refer to Get values from Parameter Entity


How to Count the Entries of a Search in an Entity

Image:Bulletazul.gif You can use the following expression to count the entries of a Search in an entity:


oEntEntiyNameList.Length

oEntEntityNameList: Variable where the entity was instantiated


Image:Business_Rules13_Image003.jpg


How to Modify Information in the Entries of an Entity

Image:Bulletazul.gif You can use an Expression containing the following in a For or a While to modify the entries of an Entity.

oEntEntiyName = oEntEntityNameList[i];

oEntEntiyName.Attributes["AttributeName"].Value = Value;

oEntEntiyName.Attributes["AttributeName1"].Value = Value1;

oEntEntiyName.Update();


oEntEntityNameList: Variable where the entity was instantiated

i: Row number.

oEntEntiyName: The name of the variable used to find a row of the entity.

AttributeName1…n: Name of each of the entity’s attributes to be modified..

Value1…n: Value that the entry will take on, which can be the value of an attribute, a variable or a constant.  The type of value must be taken into account.

 

Image:Business_Rules13_Image004.jpg


Delete Entries from an Entity

Image:Bulletazul.gif Use an expression to delete the entries that meet a condition.

oEntEntiyName = oEntEntityNameList[i];

oEntEntiyName.Delete();


oEntEntityNameList: Variable where the entity was instantiated according to a given filter.

'i': Row number

oEntEntiyName: Name of the variable used to find the row of the entity

 

Image:Business_Rules13_Image005.jpg


Add Entries to an Entity

If the user wants to add records to a Parameter table, it has to be done through Bizagi Studio the Word Portal: Include Values in Parameter Entities. To add records to a table, use the function addRelation

It is not recommended to include records to Master entity through a rule. This has to be donde in the Forms or via an Expression.

Filter dates using Entity Manager

Dates that have been saved in the data model via the Work Portal (Creating Forms), are stored in the data base including minutes and seconds, since all dates are Date-Times. Then, to access those dates using entity manager, it is necessary to convert the date in a format that can be easily read.

To illustrate an example of this situation, assume you have a Purchase Request process in which purchase orders are created as soon as a supplier is selected. All the information of the purchase order is entered in the Work Portal, including the payment dates.

Then, you have another process called Accounts Payable in which you need to find all pending purchase orders that need to be paid in the next week, in order to pay them. To do that it is necessary to use Entity Manager and choose from the Purchase Orders entity all purchase orders that have not been paid and have a payment date in the near future. We created an expression On Enter of an automatic task that will select the Purchase Orders and then will shown them in the first manual activity: Select invoices.


The following is the required code for the Expression that will select from the chosen entity, in this example the Purchase Orders entity, filtering by date.

FirstDate = Convert.ToDateTime(<Process.Date1>);
DateToFilter = "CONVERT(DATETIME,'"+String.Format("{0:MM/dd/yyyy}"+"'", FirstDate)+", 102)";
ListOfRecords = CEntityManager.GetEntity("EntityToFilter").GetEntityList("","","DateAttribute = "+  DateToFilter +"","");



<comments />