Performing actions on collections

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Define Forms > Customizing controls behavior > Actions and Validations > Actions components >

Performing actions on collections

Actions can be defined to affect collections (tables in the Work Portal). There are basically two thing that can be affected on tables using Actions:

 

Change the behavior of the cells of a specific table.

 For example, change the color of a cell, based on a condition.

Affect the behavior of the entire table.

 For example, hide the entire table, based on a condition.

Affect the behavior of controls outside a table, based on the values of a record of a table.

 For example, calculate the value of an attribute based on the sum of the records of a table.

 Keep in mind that this scenario only works with Inline Add and Inline Edit.

 

When you need to affect a specific cell of a table it is necessary to select an advanced option that allows changing the context and working with a chosen table, rather than with the whole form.  This option is found at the top of the action and it is called Applies to.

Applies to refers to the target of the Action; it can be the entire Form (selected by default) or a specific table.

 

We say that the contexts changes when one of the collections is selected. The Action created with a changed context applies exclusively to the collection chosen.

Once the context is changed to a specific collection the following constraints are applied:

 

Only elements (columns) of the collection will be available to be evaluated in conditions.

Actions will evaluate each row independently.

 

ActionsandValidations50

 

 

note_pin

If you have in your form two collections with the same Xpath, that are filtered, Actions & Validations cannot be used.

When using two tables that are filtered, you need to use the control's expressions (visible, required, editable).

 

Example: use an action to affect the color of a cell.

Example: use an action to hide or show a table

Example: use an action to set a value to a control outside of a table

 

 

Using actions to change the color of a cell

When you need to affect the column or cell of a table, there is a need to change the context.

 

Suppose you are defining a form for an activity in the Credit Request process. In the Register Request activity, a credit analyst enters the customer information related to the credit request.

 

A customer can request several products in a single loan application. Each product will contain the amount requested, and a maximum loan amount allowed for that product based on the customer payment and risk analysis.

 

If the amount requested for a product is less than the maximum amount stipulated, it should display in a green font. Otherwise it should show in red.

 

1. Build the form.

Note that the requested products are included in a collection called Products.  Include the Product name, the Maximum amount and the Requested amount as columns of the table.

 

 

ActionsandValidations12

 

 

2. Create the Action.

On the Forms designer select Actions & Validations and add a new Action.

 

ActionsandValidations44

 

3. Define the context of the action.

In this case the action will be evaluated and applied over specific elements of the Products collection, thus it is necessary to select Products in the Applies to field.

 

 

ActionsandValidations51

 

4. Include the condition.

Click Add a condition and select the control, operator and argument as follows.

When Products.Requested amount greater than Products.Maximum amount.

 

 

ActionsandValidations13

 

 

Note that if actions are defined at collection level, the elements of the collection (table column) are identified by the collection name followed by a period (.) and the element name. (i.e. collection.columnname).

 

ActionsandValidations14

 

5. Include the Action (Then). Click Add an action and define what will happen when the condition above is met.

Set background for Products.Requested amount to red.

 

ActionsandValidations15

 

Again, note that reference is made to the columns of the Products collection.

 

ActionsandValidations16

 

6. Define the Else Action, that will execute when the condition is NOT met.

Change visibility for Products to green.

 

 

ActionsandValidations18

 

This is how the Work Portal will look like according to the end user's choice:

 

ActionsandValidations25

 

 

Using actions to show or hide a collection

In this case you can hide and show a table just as you hide and show any control on the Form. There is no need to change the context.

 

Suppose you are defining a form for an activity in the Credit Request process. In the Register Request activity, a credit analyst enters the customer information related to the credit request.

 

A customer can request several products in a single loan application. Each product will contain the amount requested, and a maximum loan amount allowed for that product based on the customer payment and risk analysis.

 

If the customer's payment capacity is less than 1000, products cannot be requested so it is not necessary to show the product's table.

 

In order to show or hide the product's table according to the value entered in the payment capacity field, you can use actions.

 

 

1. Create the Action.

On the Forms designer select Actions & Validations and add a new Action.

 

ActionsandValidations44

 

2. You don't need to change the context of the Action. Leave the Form option selected in the Applies to field.

 

 

ActionsandValidations52

 

3. Include the condition.

Click Add a condition and select the control, operator and argument as follows.

When Payment Capacity less than 1000.

 

ActionsandValidations45

 

4. Include the Action (Then). Click Add an action and define what will happen when the condition above is met.

In this case hide the Product´s collection.

Change visibility for Products to false.

 

Note that collections are referenced in the same way as all other attributes.

 

ActionsandValidations46

 

5. Define the Else Action, that will execute when the condition is NOT met.

Change visibility for Products to true.

 

 

ActionsandValidations47

 

This is how the Work Portal will look like according to the end user's choice:

 

ActionsandValidations49

 

Using actions to set a value to a control outside of a table

Actions can be used to define when a column changes. This allows executing the desired actions without refreshing the entire form. Only the controls specified to be refreshed will be updated.

 

Example

In a Purchase Request Process,it  is required to calculate the total cost of a purchase including taxes and discounts.

When Total Price changes on any of the products included, or the user deletes a row, an expression is executed to obtain the total Cost of the purchase.

We want the Total Cost control to be updated when the Total Price column changes or the user deletes a row, we should use an action.

 

 

Action68

 

1. Create the Action.

Select Actions & Validations and add a new Action.

Since we are including controls OUTSIDE of the table in this Action, then the context should be Form.

 

2. Include the condition.

Click Add a condition and select the table column in the controls field. The changes option will be available to identify when the field has been changed. Add also an action to identify when the table has a row deleted.

 

Action69

 

The condition would be

Requested Products.Total Price changes

   or Products Requested has a row deleted

 

 

Action70

 

3. Include the Action (Then).

Click Add an action and define what will happen when the condition above is met.

Select Execute rule as the command and then find the rule on the expressions editor.

 

Action71

 

In this case the rule to totalize the purchase's cost is called Calculate Total Cost.

The action would be Execute rule Calculate Total Cost

 

Action72

 

 

4. Update affected controls.

Click Add an action and define the controls that have to be updated after executing the rule. To do so, use the Refresh command.

 

In this case, the control to refresh is Total Cost.

Refresh Total Cost.

 

 

Action73

 

 

 

5. Define the Else Action. In this case no action will execute when the condition is NOT met so leave this option in Do nothing.

 

 

Action74