A BPD that was started by a case (as a case activity) already knows its case: tw.system.currentProcessInstance.caseFolderId and caseFolderServerName identify the case folder. Through them the process reads and writes case properties, adds documents and completes the activity:
// service flow inside the case activity's BPD
var folderId = tw.system.currentProcessInstance.caseFolderId;
var server = tw.system.currentProcessInstance.caseFolderServerName;
// read the case folder (ECMFolder) with its properties
var caseFolder = tw.system.ecm.getFolder(server, folderId);
var amount = caseFolder.properties.get("CLM_Amount");
// update a case property (property list of ECMProperty)
var props = new tw.object.listOf.ECMProperty(); var p = new tw.object.ECMProperty(); p.objectTypeId = "CLM_Status"; p.value = "REVIEWED"; props[0] = p;
tw.system.ecm.updateFolderProperties(server, folderId, props);
// file a document into the case folder
tw.system.ecm.createDocument(server, folderId, "Decision.pdf", "application/pdf", tw.local.pdfBase64, true /*base64*/, null);When the process ends, the case activity completes automatically and the case's rules / other activities react (activity preconditions on properties). Three more channels:
- Case properties as BPD variables: the activity's data mapping (case properties <-> process variables) is declared in Case Builder; values mapped as output are written to the case when the activity completes - no code.
- Case REST API from any BPD (also processes that are not case activities): PUT /CaseManager/CASEREST/v1/cases/{caseId} with the properties; POST .../cases/{caseId}/comments for comments.
- Events: a BPD can send an event message (UCA) that a Case "wait on message" activity or an integration listens to, and Case can start BPDs (question 2926).
References