Performing actions on collections

<< Click to Display Table of Contents >>

Navigation:  Low-code Process Automation > Studio Cloud - Authoring environment > 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 Context.

Context 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. Hence, it is necessary to select Products in the Context field.

 

ActionsandValidations51

 

4. Include the condition (If).

Select the control, operator and value as follows.

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 the Add button and define what will happen if the condition above is met.

set background for Products.Requested Amount to red (#ff0000 hex color code)

 

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

 

ActionsandValidations15

 

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

set background for Products.Requested Amount to green (#008000 hex color code)

 

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.

 

note_pin

We strongly suggest that if you choose to use Actions to control visibility, all visibility definitions must be done with actions.

Beware that combining visibility Actions with visibility Expressions will most likely fail in runtime.

 

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 Context field.

 

ActionsandValidations52

 

3. Include the condition (If).

Select the control, operator and value as follows.

Payment Capacity less than 10000

 

ActionsandValidations45

 

4. Include the Action (Then). Define what will happen if the condition above is met.

In this case hide the Products collection.

change visibility for Products to No

 

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

 

ActionsandValidations46

 

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

change visibility for Products to Yes

 

ActionsandValidations47

 

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

 

ActionsandValidations49

 

note_pin

Bear in mind that even if a column is not visible, it will be available when defining actions, and will be affected by them since the column is included in the project's metadata.

 

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.

If 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.

As we want the Total Cost control to be updated if 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 (If).

Select the table column in the controls field. The changes option identifies if the field has been changed. Add also an action to identify if the table has a row deleted.

 

The condition would be

Product Requested.Total Price changes

   Or Products Requested has a row deleted

 

Action69

 

3. Include the action (Then). Define what will happen if the condition above is met.

Select execute rule as the command and then find the rule on the Expression manager.

 

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 the Add button 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 if the condition is NOT met, so leave the action configuration as it is.


Last Updated 7/19/2023 4:44:59 PM