Below is JS code we used in IBM Case Manager to update BO on user actions on a case detail page. You can try and see if you can leverage similar concept.
require(["icm/base/Constants", "icm/model/properties/controller/ControllerManager"],
function(Constants, ControllerManager) {
/* Get the coordination and editable objects from the event payload. */
var solutionPrefix = payload.caseType.getSolution().getPrefix();
var coordination = payload.coordination;
var editable = payload.caseEditable;
/* Use the LOADWIDGET coordination topic handler to obtain the controller binding */
/* for the editable and to update the properties. */
coordination.participate(Constants.CoordTopic.LOADWIDGET, function(context, complete, abort) {
/* Obtain the controller binding for the editable. */
var collectionController = ControllerManager.bind(editable);
/* Start a batch of changes. */
collectionController.beginChangeSet();
/* Build the values for the Business Object Members */
/* Assume all members to contain data for all rows */
/* In the view, we would see two rows like */
/* 10, Baker Street, Costa Mesa, Oasis, California, USA*/
/* 20, Ebay Street, Costa Mesa, Lotus, California, USA */
var propValues = {};
propValues.SAT_HouseNumber = ["10","20"];
propValues.SAT_StreetName = ["Baker Street","Ebay Street"];
propValues.SAT_CityName = ["Costa Mesa","Costa Mesa"];
propValues.SAT_PropertyName = ["Oasis","Lotus"];
propValues.SAT_StateName = ["California","California"];
propValues.SAT_CountryName = ["USA","USA"];
/* Get the property Controller of the Business Object. For instance, SAT_Residence */
var residenceController = collectionController.getPropertyController(solutionPrefix + "_Residence");
/* Get the members of the Business Object */
var children = residenceController.getAttribute("boChildren").get();
/* Set the individual value arrays to the child controllers */
/* This would help in displaying the changes on Add Case */
for(var j=0;j < children.length; j++) {
var childController = collectionController.getPropertyController(children[j]);
var propname = solutionPrefix + "_" + childController.getAttribute("name").get();
childController.set("value",propValues[propname]);
}
var num_values = propValues.SAT_HouseNumber.length;
/* Loop through the values and set it to the Business Object Controller. */
var values = [];
for(var i=0;i < num_values; i++) {
var updateJson = {};
updateJson.id = null;
var props = [];
updateJson.properties = props;
for(var j=0;j < children.length; j++) {
var prop = {};
var childController = collectionController.getPropertyController(children[j]);
prop.name = solutionPrefix + "_" + childController.getAttribute("name").get();
prop.dataType = childController.type;
prop.cardinality = childController.cardinality;
prop.value = propValues[prop.name][i] ;
props.push(prop);
}
values.push(updateJson);
}
residenceController.set("value", values);
/* Complete a batch of changes. This tells all subscribed widgets to refresh. */
collectionController.endChangeSet();
/* Call the coordination completion method. */
complete();
});
/* Use the AFTERLOADWIDGET coordination topic handler to release the controller binding for the editable. */
coordination.participate(Constants.CoordTopic.AFTERLOADWIDGET, function(context, complete, abort) {
/* Release the controller binding for the editable. */
ControllerManager.unbind(editable);
/* Call the coordination completion method. */
complete();
});
});
------------------------------
Nitin Upasani
------------------------------
Original Message:
Sent: Mon April 05, 2021 08:25 AM
From: DAVID Jenness
Subject: Is it possible to update Business Object data of a process instance using JavaScript API ?
Let me ask a BPM expert I know to look into this...
------------------------------
DAVID Jenness
Original Message:
Sent: Mon March 22, 2021 08:10 PM
From: Eduardo Izquierdo Lázaro
Subject: Is it possible to update Business Object data of a process instance using JavaScript API ?
I mean, without using local variables tw.local.*
The idea is that a process instance running a ServiceFlow can use JavaScript to search for another instance (tw.system.searchInstanceBiId()) to update a BO on that instance.
Thanks.
------------------------------
Eduardo Izquierdo Lázaro
------------------------------