Tuesday 14 April 2015

Create Work item through existing Workflow (Process Engine API)

//Create Work item through existing Workflow (Process Engine API)


public VWCreateLiveWOResult[] createLiveWorkObject( java.lang.String[] fieldNames, 
java.lang.Object[] fieldValues, 
java.lang.String workflowIdentifier, 
int numberToCreate) 
throws VWException

will creates (initializes, saves, and dispatches) work items from a transferred workflow definition, specified by its workflow identifier. Multiple work classes on one roster are supported

fieldNames - A String array containing the names of the fields to update in the new work items, in the same order that the values for those fields are supplied in the fieldValues parameter.

fieldValues - An array of Objects whose values are supplied, in order, to the fields named in the fieldNames parameter. 

workflowIdentifier - The workflow definition name (work class name) as returned by VWWorkflowDefinition.getName method, or the workflow version (version property) as returned by VWTransferResult.getVersion. You can get a VWTransferResult object using the transfer method. If a translation source exists, the authored work class name is translated.

numberToCreate - An integer for the number of work items to create. 


try {
      String[] myWorkObjectNumbers = (String[])null;
      String[] myRosterNames = (String[])null;

      VWCreateLiveWOResult[] createWORes = this.peSession
        .createLiveWorkObject(myFieldNames, myLaunchValues, myWorkflowName, 1);

      if (createWORes[0].success())
      {
        myWorkObjectNumbers = new String[createWORes.length];
        myRosterNames = new String[createWORes.length];
        for (int i = 0; i < createWORes.length; i++) {
          myWorkObjectNumbers[i] =
            createWORes[i].getWorkObjectNumber();
          log.info("New workflow with Wob Number [" +
            myWorkObjectNumbers[i] +
            "] launched successfully");
          myRosterNames[i] = createWORes[i].getRosterName();
          log.debug("Workflow Roster Name is [" + myRosterNames[i] +
            "]");
        }

      }

    }
    catch (Exception ex)
    {
      log.error("Exception occured while launching workflow:" +
        ex.getMessage(), ex);
      throw ex;
    }

  






No comments:

Post a Comment