Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

createWork(className, options)

Updated on July 20, 2021

Creates a work object for a specified class and flow type and displays the work object in a target container.

Returns

A Promise associated with the action.

Parameters

NameTypeDescriptionRequired
classNamestringName of the case class for which the work object should be created.
optionsobjectThe JavaScript object that contains the properties required for creating the work object.

The following table contains the properties of the options object:

NameTypeDescriptionRequired
flowType stringThe type of flow based on which the work object is created.
Note: The default value of this property is pyStartCase.
containerNamestringThe name of the container that displays the created work object.

Example:

{flowType: "pyStartCase", containerName: "primary"}
openCaseViewAfterCreateboolean
Note: You must update to Pega 8.7.1 or later patches to be able to use this property.
The flag that determines if the new case view should be displayed when a case is created.
Note:
  • The default value is true.
  • Set openCaseViewAfterCreate to true if the new case view should be displayed when a case is created.
  • Set openCaseViewAfterCreate to false if the new case view should not be displayed when a case is created.
startingFieldsobjectThe JSON object that contains the fields to be set while creating a case.

Usage example

In this example, the API creates a work object within the primary container with the OPB1HW-SpaceTra-Work-RequestApproval class and the pyStartCase flow type.

const options = {
     flowType: "pyStartCase",
     containerName: "primary",
     startingFields: {
         FirstName: "Adam",
         LastName: "Smith",
         Vehicle: {
             Make: "Honda",
             Model: "Accord"
         }
     }
 };

const createWorkPromise = getPConnect().getActionsApi().createWork("OPB1HW-SpaceTra-Work-RequestApproval", options); 
createWorkPromise.then(() => {
  // create work success handling
}).catch(() => {
  // create work failure handling
});

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us