Content

Overview

Creating Action Blocks in the Graphical Editor

Graphical Editor Overview

Adding Actions

Setting Action Properties

Specifying Property Values as Groovy Expressions

Block Properties

Conditional Blocks

Return Properties

 

Script Editor

Overview

Creating Action Blocks in the Script Editor

 

Overview

Top ../images/arwup.gif (846 bytes)

An "Action Block" is a series of Actions that are executed sequentially, and may be driven by conditional logic as required.

The Action Block Editor lets you create Action Blocks using either a graphical editor, or an editor designed to work with Groovy script. This feature is integrated into this LabVantage functionality:

Functionality Use
Actions Create an Action Block that is defined as a User Action (in the System Admin → Security → Actions tramstop, choose "Action Block" as the "Action Language").
Data File Definitions Create the Processing Script that determines how LabVantage imports data from a file.
eForms Create the Processing Script that determines what happens to data entered into a Form.
Event Plans Create Event Functions that define what happens when an Event fires.
Workflows Create Processing Scripts for Workflow Step Definitions and Workflow Task Definitions.

 

Creating Action Blocks in the Graphical Editor

Top../images/arwup.gif (846 bytes)

Graphical Editor Overview

 

The "Graphical Editor" offers a pictorial view of the Action Block.

  Frame Description
1. Object Defines graphical components that can be used to create the Action Block.
2. Editing Shows the Action Block and provides basic labeling functions.
3. Properties Defines Action properties.

The Toolbar contains these specialized buttons:

Button Description
Switch to Groovy Changes views to show the Script Editor (available only in eForms and Event Plans).
Test This is a debugging tool that executes a processing run and provides debug messages (available in eForms and Actions). You can enter property values and test the script for syntax and property definitions.

The behavior of the "Test" button is determined by the "Ajax Requests → Allow Groovy Calc Test Execution" property in the Security Policy, which can be set to actually execute the script (change the database), or only check syntax but not actually execute the script.

Adding Actions

 
  To find an Action, the "Search By" utility features type-ahead (left).

Expanding "Common Actions" lets you choose from the most commonly-used Actions.

You can also find "Actions By Category".

  To add an Action, drag it from the Object frame to the desired Action Block in the Editing frame (left).

Action Properties are displayed in the Properties frame:

You can edit both the Action name used in the Action Block ("action0" in the example above) and the Action Label used to identify it ("AddSDI" in the example above).

Setting Action Properties

 

Set Action Properties as follows:

Using lookups where available:

 

  By entry with type-ahead:

"Available Properties" represent values defined by the tool that launched the Action Block Editor. In the example below, the Action Block is executed from a Workflow Task Definition Maintenance Page, so "Available Properties" shows the variables you created (and are therefore available) in that particular Task Definition. By dragging and dropping the variables into the Action property fields, you automatically get the context of the variable from its source, i.e., the Workflow Task Definition:

In the example below, the Action Block is executed from a Form Definition. The "Available Properties" therefore shows all Fields in the Form that are available for use as variables in the Action properties:

Specifying Property Values as Groovy Expressions

 

You can also define and evaluate property values using Groovy expressions. Pressing Alt-G inserts [$G{}]. This is a Groovy block with an undefined closure. The closure can be used to create Groovy expressions that involve any "Available Property".

First, consider that any "Available Property" can be simply defined within the closure. In the example below, the [sampleid] variable is available as a Form Field. As such, it can also be defined as [$G{fields.sampleid.toString()}]. Note that a data type conversion is required to enable evaluation of the expression by the Action (such as toString() in this example).

This functionality extends to evaluation of Groovy expressions. The example below is defined by Form Processing in an eForm Form Definition. The expression evaluates the Parameter List Version, setting it to 1 if null or the version number if not.

NOTE:   When using the Action Block Editor in a Data File Definition, the syntax above works only if the Data File Definition's "Process Block Size" is set to 1 item. If set to more than 1 item, multiple values are returned in a list. In this case, an alternate syntax is required.

See Data File Definition → Creating a Processing Script and Data File Definition → Groovy Utilities.

Block Properties

 

You can create "Block Properties", which are available for use throughout the entire Action Block.

The easiest way to create a Block Property is to create one using an Output Property. Note the "Create Block Property" column below. This shows the Output Properties currently available in the Action Block. Each is created using the format [action.property]. In the example below, [action0.newkeyid1] is the default variable created for the "newkeyid1" property of "action0", which is the AddSDI Action. To create a Block Property for this output, enter the new name for the variable. In the example below, we name the Block Property [newsampleid]. The new Block Property is then added to the "Available Properties" as shown.

You can then use this new Block Property by dragging it to the desired Action Property as shown in the example below.

A "New Block Property" can also be dragged into the Action Block from the Chart Objects. This is generally used for advanced operations such as when you want to evaluate a Groovy expression throughout the block, or to create references (such as setup a literal string for reference). Note that when referencing Block Properties, Groovy expressions use the "block" object as shown in the example below, where the output is tested for the existence of a string value.

Checking "Is Groovy Expression" opens a text editor that lets you enter a Groovy expression rather than choose from the list of variables. When using this Groovy editor, Ctrl-Space provides a list of all objects, methods, and variables available. For example, when creating a Form Definition using eForms technology, the "Form Processing" engine exposes a number of discrete variables and methods. These are listed in Form Definitions → Form Processing. The example below shows how Ctrl-Space provides variables and methods for use with the Form Processing expression:

Conditional Blocks

 

Conditional Blocks let you execute a series of Actions based on conditional expressions. To add, drag "New Conditional Block" from the "Chart Objects" to the desired location in the Action Block as shown below.

The easiest way of defining conditional expressions is to use the provided editor as shown below. This provides dropdowns and lookups to help you find the available properties and establish conditions for each. Multiple conditions are evaluated using an "And" operator (denoted by an ampersand in the GUI). If you enable "Is Groovy Expression", the expressions created in the editor are not converted to Groovy (and vice-versa). The example below tests to determine if the subject is a male born on or after the specified date, then add different Data Sets based on the evaluation.

Also note that, as shown below, Conditional Blocks can evaluate Actions in both the "true" and "false" branches.

A "New Conditional Block" can also be dragged into the Action Block from the Chart Objects. This is generally used for advanced operations such as when you want to evaluate a Groovy expression throughout the block, or to create references (such as setup a literal string for reference). Note that when referencing Block Properties, Groovy expressions use the "block" object as shown in the example below. This example sends a Bulletin when the KeyId1 string exists.

When specifying conditional expressions for Event Plans, you must preface the expression with "inputs". For example, if the column used as input is s_sample_productid and you want the condition to be only when the ProductId is "ProductA", the expression would be: inputs.s_sample_productid == "ProductA".

Return Properties

 

"Return Properties" apply to the entire Action Block. Return Properties are designed to return a value back to the caller of the Action Block. For example, if the Action Block was called from a Form Definition, a Return Property can return a key or message after Form submission. You can also do things such as redirect to a List page with "newkeyid1" submitted (see the Form Processing Output Directives for an example of this). Note that returning Fields in the output map in Groovy has the same effect.

When creating a new Return Property, you are required to provide a name for the property in order for the property values to be shown. Return Property values then provide a selection list that includes Block Properties and all Action Output Properties.

 

Script Editor

Top ../images/arwup.gif (846 bytes)

Overview

 

The "Script Editor" is provided for Groovy script. This is activated by "Switch To Groovy" on the toolbar, which is available only in eForms and Event Plans.

The Editing Panel provides basic editing functions. The Toolbar contains these specialized buttons:

Button Description
Switch to Action Block Changes views to show the Graphical Editor (available only in eForms and Event Plans).
Test This offers the same debug capabilities as in the Graphical Editor.

Creating Action Blocks in the Script Editor

 

To add Actions to the Action Block, drag the Action from the Action List and drop it into the desired location in the Editing frame.Action properties and a processAction call are added.

To set Action properties, drag the variable into the required property. The example below shows an application based on eForms functionality. AddSDI is required to create Samples when a user fills in a Form Field. In this case, we enter the SDCId ("Sample"), but drag the returned KeyId1 ("newkeyid1") from Available Properties. Note that in Forms, values are prefaced with the object name (such as "fields" and "groups" above).