Introduction
In Process Designer, variables
capture the business data that is used by activities in a business process
definition or by steps in services such as integration services or human
services. Each variable has its own type and scope. All variables you create must
be declared before you can start using them.
Variable
types in Process Designer
You can use the variable types
provided by the system toolkits, such as the System Data toolkit, or you can
create custom business objects, depending on the requirements of the business
data included in your process.
During Process Designer
installation, the system toolkits are imported into the Process Center
repository so that each process application and toolkit that you create has
access to a common system data. The system toolkits provide the following
categories of variables:
Base Types
Base types allow you to create
custom variable types called business object. A list of all the base types is
provided further in this topic.
System Types
System types are provided variable
types that cannot be modified. A list of all the system types is provided in
the JavaScript API reference guide.
Table 1. Provided base types
|
|
Base types
|
Description
|
String
|
Allows alpha-numeric characters to be entered
into the variable.
|
Integer
|
Accepts digits without a decimal place, such
as 45 or 20.
|
Decimal
|
Accepts digits with up to two decimal places,
such as 45.3 or 20.13.
|
Date
|
Allows date and time formats to be entered into
the variable.
|
Time
|
Allows date formats to be entered into the variable
as times. The user enters a time, and before the variable is entered into the
symbol table, it is converted to and behaves like a date.
|
Selection
|
Allows you to provide a list of possible entries
to a user, of which the user can select only one. A selection is a list of
different values; each value is typed as a string. A selection variable
appears at run time on a Coach form as a drop-down list or as radio buttons.
|
Boolean
|
Accepts
either true or false as values. It appears at run time on
a Coach form as a check box.
|
Structure
|
To use a structure type, you need to create a
custom structure type and define its properties. A structure regroups
business data that is related to the same subject. For example,
a Customer structure might contain elements such
as lastName, firstName, homeNumber, streetAddress.
|
Custom Variable Types
Custom variable types are
defined using business objects. If the predefined business objects provided in
the system toolkits do not represent your needs, you can create your own
business objects.
Variable Scope in Process Designer
In IBM® BPM, all variables
declared for a business process definition (BPD) or service are local
variables.
Local variables are only
accessible to the currently executing process instance or service. Because
variables are unique to an individual BPD or service, you can use a variable of
the same name in a nested BPD or service and there are no conflicts at run
time.
Table 1. Available namespaces
|
|
Namespace
|
Description
|
tw
|
Top-level Process
Designer namespace
|
tw.object
|
Access Process
Designer JavaScript objects and business objects (variable types)
|
tw.local
|
Access
and update BPD and service-level variables
|
tw.system
|
Access
system features and functionality
|
tw.system.org
|
Access
security functionality
|
tw.epv
|
Access
exposed process values (EPVs)
|
tw.env
|
Access
environment variables
|
Initializing Complex Variables and Lists
Before using a complex
variable, initialize it by using a script like the following:
If the variable is a complex object
tw.local.<variableName>=new
tw.object.<businessObject>();
Example:
tw.local.customer=new tw.object.CustomerBO
();
If the variable is a list,
use: tw.local.<listName>=new tw.object.listOf.<businessObject>();
Example:
tw.local.customerList= new tw.object.listOf. CustomerBO ();
Assigning Data to Object
tw.local.customer.id = “C123”
tw.local.customer.name = “BlueMix”
Conclusion
In IBM Process Designer, we
can create a custom business object by using a base business object or by
defining a new complex structure. When you create a business object in a
process application, that object is available for all business processes, case
types, and services in the process application. If you want to share a custom
business object across process applications, create or store the custom object
in a toolkit. Then, create a dependency on that toolkit from the process
applications that require the variable. We have learnt how to create Business Object
and Initialization of Business Object.