IBM BPM, V8.0.1, All platforms > Create processes in IBM Process Designer > Modeling processes > Business objects and variables

Create business objects

When no system data toolkit variable types or business objects match your specifications, you can create custom variable types called custom business objects.

To complete the following steps, you must have write access to a process application or toolkit in the Process Center repository. Access to process applications and toolkits is controlled by users who have administrative rights to the repository.

In Process Designer, you can create a custom business object by using a base business object or by defining a new complex structure.

When you create a new custom business object in a process application, that object is available for all BPD and services included 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 and then create a dependency on that toolkit from the process applications that require the variable.


Procedure

  1. In Process Designer, open your process application.

  2. In the library, expand Data and click Business Object. The New Business Object window opens.

  3. In the Name field, type a name for the custom business object and click Finish.

    Remember: Names of business objects are case sensitive.

  4. In the Behavior section, select a definition type from the Definition Type list.

    Simple Type

    Creates a new business object using an existing type such as String, Decimal, and Integer and further constraints based on pattern, length, or value. A simple type created with the business object editor should not be initialized before use with a business process or service unlike a complex type. If you do initialize a simple type using the new keyword then you will receive a runtime error.

    Complex Structure Type

    Creates a new complex business object by specifying the parameters for the structure.

  5. Select a type in the Definition Type list.

    • If you selected Simple Type, select the type of your business object in the Type list and specify a validation rule in the Validation section.

    • If you selected Complex Structure Type, add the required parameters by clicking Add, and set values for Names and Variable Types in the Parameter Properties section.

  6. Select the Shared Object check box if the business object and its values should be accessible to other instances at run time. The business object will become a shared object.

    • Shared business objects only apply to a complex structure type.

    • The data within a shared business object is shared between business processes and tasks.

      You can send data from one process to a second process using a Message Event or by loading the data into the second process using the unique key of the shared business object. To load the data, get the unique identifier key and then load the instance using the key.

      For example in the following code, sharedBusinessObjectKey would be obtained by running tw.local.myVariable.metadata("key").

      tw.local.myVariable = new tw.object.mySharedBusinessObject(sharedBusinessObjectKey);

    • A shared business object uses database resources. The data within a shared object is persisted to the database when:

      • The shared object is created

      • The business process or task is persisted to the database

      • The JavaScript method save() is performed on the shared business object.

    • Each shared object is logically connected to the business process instance that created it. When the business process instance is deleted (for example, when you delete a business process instance that was running in the Inspector), the shared object data in the database is also deleted.

    • If you clear the Shared Object check box at a later point in time, the business object will no longer be accessible to other instances at run time.

    • If the shared business object is created within a Human service that can be started and that activity is not bound to a business process instance, the shared business object is connected to the activity's task instance. In such cases, the shared business object is deleted if the task instance is deleted.

    • If a shared business object is deleted from the database, the behavior of the tasks or processes that reference the shared business object is undefined.
    • Best practice for shared business objects: If you want to create shared business objects that have a long lifetime, you may want to design a business process that acts as a factory (that is, it is based on a factory method pattern). The result is your shared business objects will remain in the database until the factory business process is deleted.

    • An output shared business object for an external service, such as a web service, and an Advanced Integration Service will return a new and typically updated copy of the original input shared business object. Therefore, your application should not reference the input shared business object expecting an updated value if your application is working with an external service or an Advanced Integration Service. It should reference the new output shared business object.

  7. To save your custom business object, click Save.


What to do next

You can declare new variables of the type you just created.

You can create and retrieve the shared business objects you have created by using a key. In this case, tw.object.SharedObject is the shared business object.

// Create shared object sharedObject.taskId = "init";
sharedObject.save();

// Create key for shared object tw.local.sharedObjectKey = sharedObject.metadata("key");
log.info("sharedObjectkey: " + tw.local.sharedObjectKey);

// Retrieve shared object by key
log.info("sharedObject2.taskId: " + sharedObject2.taskId);

Business objects and variables


Related concepts:
Variable types in Process Designer
Example: validating a Coach with a service


Related tasks:
Create exposed process values (EPVs)
Visualize variables


Related reference:
Business object advanced properties


Related information:
JavaScript API reference