IBM FileNet P8, Version 5.2.1            

Creating a Workflow Instance

Creating a workflow instance is a prerequisite set of operations for a Launch Step Processor to launch a workflow.

To create a workflow instance, create a class to do the following actions:

  1. Create the workflow definition object
  2. Transfer the workflow definition object
  3. Validate that the transfer was successful
  4. Retrieve the transfer result version
  5. Create the workflow instance
  6. Launch the workflow

To facilitate development, you might want to adapt the API sample constructor for LaunchSample.

Create the Workflow Definition Object

Create a workflow definition object from an object store, file store, or Content Services library file by using VWWorkflowDefinition.readFromFile().

Note: A local workflow definition (a *.pep file) must exist. Use either the VWWorkflowDefinition constructor, or the constructor for the WFDefinitionSample sample class.

Transfer the Workflow Definition Object

If the workflow was already transferred to the Process database and was not changed, the transfer is not necessary. However, if the workflow was not transferred, or if there was a change in the workflow, the transfer is required.

Transfer the workflow definition object to the Process database by using VWSession.transfer(). Specify the Content Platform Engine (or Content Services) docid as a parameter to identify the workflow definition. For example:

  // Transfer the workflow definition object, where the second parameter is a unique id.
  
  VWTransferResult transferResult = m_vwSession.transfer(wflDef, uniqueid, false, true);

Validate The Transfer

After you transfer the workflow definition object to the database, validate and log whether the transfer was successful, and display the transfer errors.

if (transferResult.success()) {
    m_logger.log("The transfer was successful.")

    // ( less significant code . . . )
    }
    else {
    // Display the transfer errors.
        String[] errorArray  = transferResult.getErrors();
        if (errorArray != null)
            m_logger.log("\tThe following transfer errors occurred: ", errorArray);
        else
            m_logger.log("\t\tError messages were not available.");
    }

Retrieve the Transfer Result Version

Prepare to create the Launch step by retrieving the version that uses VWTransferResult.getVersion().

When you create the workflow that uses VWSession.createWorkflow(), use the version string that is returned from VWTransferResult.getVersion() as the argument to a VWStepElement call.

Create the Workflow Instance

Create an instance of the workflow that uses VWSession.createWorkflow(), which returns a VWStepElement object that represents the Launch step for the workflow.

You can use VWStepElement.setComment() to label this Launch step. For example:

  launchStep = m_vwSession.createWorkflow(vwVersion);
  launchStep.setComment("This is a sample workflow Launch step comment");

See also Updating Workflow Data.

Launch the Workflow

The final operation that is required of a Launch Step Processor is to launch the workflow.

Use VWStepElement.doDispatch to launch a workflow. The doDispatch() method saves changes to the database and dispatches the Work Object to the next step that is defined in the workflow definition. The saved changes are those changes that were made to the Work Object that is associated with the Step Element.



Last updated: October 2015
creating_workflow_instance.htm

© Copyright IBM Corporation 2015.