Create Case service

The Create Case service is used to create a case using a service call.

When a new Add Case Layout is created in a solution, it would be default as in the following diagram-1.

Create Case service implementation, example 1

The diagram-1 can be customized to use a service to create a case as shown in the diagram-2, by using the following procedure.

Create Case service implementation, example 2

To use the Create Case service, follow the steps:
  1. At the Start, drag the Case Properties into the drop area of the Add Case coach, by selecting them from Variables.
  2. Add a button Create Case in the Add Case coach.
  3. Add a service and name it as Create Case Service and connect the Add Case coach to the service. Make sure that the Create Case button connects the Add Case coach to the Create Case Service. Otherwise, change it to this button in the connector.
  4. In the Create Case Service, select the implementation to be Create Case Service from the Case Toolkit.
  5. In the Create Case Service, map the input and output data mapping as per Table 1 and 2.
  6. Add an exclusive gateway, which has the default flow to a new coach named as Case Details and another flow to a new coach Display error. The condition on the error path should be set to tw.local.caseTypeObject.errorString != undefined
  7. Make changes to the Display error coach to display the error message by binding the variable caseTypeObject.errorString to a Display text UI view. Add a Back button and connect the Display error coach back to the Add Case coach when the Back button is clicked.
  8. Make changes to the Case Details coach to show any existing Case views like Case Summary, and configure the configuration option Case Identifier to tw.local.caseTypeObject.caseId and Target Object Store Name to tw.local.caseTypeObject.tosName. Rest of the configuration options can be ignored.
  9. Create a new End Event and connect the Case Details coach to this End Event.
Table 1. Input mapping for Create Case service
Name Description Data type
caseType The Case Type that is passed as input to the Create Case service. Map this config option to tw.local.caseType. String
tosName The target object store Name that is passed as input to the Create Case service. Map this config option to tw.local.tosName. String
jsonProps The string representation of the JSON value of case properties that is passed as input to the Create Case service. Map this config option to JSON.stringify(tw.local.caseProperties). String
caseClientTabID The Case client tab ID that is passed as input to the Create Case service. Map this config option to tw.local.caseClientTabID. String
Table 2. Output mapping for Create Case service
Name Description Data type
result The caseTypeObject of type CaseObject that receives the output from the execution of the Create Case service. Map the output result(CaseObject) to tw.local.caseTypeObject CaseObject
Table 3. Structure of the CaseObject returned by the Create Case service
Name Description Data type
caseId The Case Identifier of the new case. String
caseData The Target object store name where the new case resides. Any
caseTitleProperty The Case Type of the new case. String
caseTypeName Data that is used internally. String
isAutoLaunch The property that indicates whether the new case must be opened automatically after creation. Boolean
errorString The error message that is sent by the Create Case service, when the service failed to create the case. String
messageString The message that the Create Case service creates upon successful creation of a case, which can be passed on to the End Event for scenarios like opening automatically the new case that got created. For example, the following code can be added to the Post Execution Script in the End Event:
if(tw.local.caseTypeObject.isAutoLaunch == true) {
    this.parent.postMessage(tw.local.caseTypeObject.messageString, “*”);
}
String