Creating a New Case Object

Within a process, you can create a case object by first creating a process data field of the case class type, using a script and other tasks to create the object and set values in it. Then use a Case Data Operations service task to create the case object from the local data (by adding the case object to the case data store).

Prerequisites

The Business Data project that contains the case class that you want to use must exist in the same workspace as the process from which you want to create the case object.

Procedure

  1. Create a new data field, of type BOM Type, which references the appropriate case class.
  2. In a script, use the appropriate factory method to create an instance of the case class as a local business object and assign it to the data field. (See Creating a Case Data Model.) For example:

    data.cust = factory.com_example_scriptingguide.createCustomer( );

  3. Populate the local business object with the appropriate data. You must assign a value for each mandatory attribute in the case class.
    Note: If the case class uses an an automatic case identifier you cannot (and do not need to) assign a value for it. You must assign values for manual case identifiers.
  4. Add a service task to the process.
  5. On the General tab of the Properties view, set Service Type to Case Data Operations.
  6. Select Create Case Object(s).
  7. In the Case Class field, select the same case class that you used to create the local business object.
  8. In the Local Data Value(s) field, enter the name of the data field that holds the local business object.
  9. Create a new data field, of type Case Class Reference, which references the same case class.
  10. In the Return Case Reference(s) field, enter the name of this field.
    When the service task is executed, the case reference for the newly created case object will be returned to this field.

Result

BPM now has two copies available of the same data - the local BOM object and the case object. These objects are separate entities and will not be maintained in step:
  • The local BOM object is only visible to the process and can only be manipulated in and by that process.
  • The case object is visible to and can be manipulated by any process that has access to its case data model.

Any updates to the case object are not automatically reflected in the local BOM object, and vice versa.

What to do next

(Optional) Add appropriate error handling to the service task boundary to deal with the following specific error that may be returned by the Create Case operation.

Error (Error Code) Description Possible solutions
NonUniqueCaseIdentifierError (NonUniqueCIDError) The manual case identifier specified in the Local Data Value(s) field cannot be used because it is not unique. An existing case object already uses this case identifier. Amend the case identifier value(s) in the local data object and retry the Create Case operation.