I think I also have this problem, but in 21.0.2 on-premise and on the service level. I want to set case properties from within a service flow which has retrieved values elsewhere.
(Using a process level script would clutter the
business process diagram and possibly require additional process variables. Mapping directly from the task output to tw.local.caseProperties.BusinessName etc would prevent running, debugging and testing the process without a parent case.)
if (tw.system.currentProcessInstance != null) {
if (tw.system.currentProcessInstance.parentCase != null) {
//DEBUG Set seems unreliable. Try to log Get first.
var propertyNamesToGet = [];
propertyNamesToGet[0] = "MESBX_BusinessName";
var propertyValuesToLog = tw.system.currentProcessInstance.parentCase.getCasePropertyValues(propertyNamesToGet);
log.info("MESBX - Current value of case property " + propertyNamesToGet[0] + " is: " + propertyValuesToLog[0]);
var propertyNames = [];
var propertyValues = [];
propertyNames[0] = "MESBX_BusinessName";
propertyValues[0] = "MOCKED BusinessName in Retrieve and Map TS: " + tw.local.identifier;
propertyNames.push("MESBX_ContactPerson");
propertyValues.push("MOCKED ContactPerson in Retrieve and Map TS: " + tw.local.identifier);
tw.system.currentProcessInstance.parentCase.setCasePropertyValues(propertyNames, propertyValues, false);
log.info("MESBX - Tried updating case properties: " + propertyValues[0] + " - " + propertyValues[1]);
}
else {
log.info("MESBX - No parent case to uodate properties for.");
}
}
This is my log output. Neither values, nor any errors, when using
getCasePropertyValues and setCasePropertyValues. The two last lines are generated from a process script. The BusinessName property has retained its initial value from the add case page, before entering the process:
[11/4/21 11:14:13:509 CET] 000001c6 LoggerScripta I MESBX - Current value of case property MESBX_BusinessName is:
[11/4/21 11:14:13:522 CET] 000001c6 LoggerScripta I MESBX - Tried updating case properties: MOCKED BusinessName in Retrieve and Map TS: {1071EA7C-0000-CA1A-9011-42C904C90BC4} - MOCKED ContactPerson in Retrieve and Map TS: {1071EA7C-0000-CA1A-9011-42C904C90BC4}
[11/4/21 11:26:42:620 CET] 000001ca LoggerScripta I MESBX - process Review Application FINALIZE - caseId is: {1071EA7C-0000-CA1A-9011-42C904C90BC4}
[11/4/21 11:26:42:620 CET] 000001ca LoggerScripta I MESBX - process Review Application FINALIZE - tw.local.caseProperties.BusinessName.value is: Overwrite Me 2 AB
------------------------------
Mattias Edling
------------------------------
Original Message:
Sent: Tue June 29, 2021 02:54 AM
From: Jyoti Korde
Subject: Uncertain behavior when setting content object at process layer
Hi,
I am currently workin on BAW v20.0.1 to create a case solution having activities implemented in bpm processes. I use script to initialize content object/case properties properties inside bpm process, however I have a noticed this initialization does not change the variables sometimes. The behavior is very uncertain.
Ultimately I had to move this code to service layer and use to make sure properties are initialized correctly everytime
tw.system.currentProcessInstance.parentCase.setCasePropertyValues
Has anyone else faced this issue? Is it a bug in the product?
Regards,
Jyoti
------------------------------
Jyoti Korde
------------------------------