Greetings!
In my IBM Case Manager solution, I need to set a value for a property when a user opens a work item.
I'm using the script below to achieve this. However, I'm encountering an issue: when the page is opened, the value I set is displayed correctly in the field, but the page is marked with an asterisk (*), indicating that it has unsaved changes. As a result, I have to save the changes manually before closing the page.
What I need to do is automatically save these changes within the script, so that manual saving on the page is not required. For reference, I am using the incoming event "send work item" for the page container to handle this.
require(["icm/base/Constants", "icm/model/properties/controller/ControllerManager"],
function(Constants, ControllerManager) {
// Get the coordination and editable objects from the event payload.
var coordination = payload.coordination;
var editable = payload.workItemEditable;
// Handler for LOADWIDGET topic
coordination.participate(Constants.CoordTopic.LOADWIDGET, function(context, complete, abort) {
// Obtain the controller binding for the editable.
var collectionController = ControllerManager.bind(editable);
if (!collectionController) {
alert("Failed to bind the controller.");
return;
}
// Start a batch of changes
collectionController.beginChangeSet();
// Make updates to the properties
var propertyController = collectionController.getPropertyController("BAM_PROPERTY");
if (propertyController) {
propertyController.set("value", "123456789");
propertyController.set("readOnly", true); // Set read-only if needed
} else {
alert("Failed to get the property controller for BAM_PROPERTY.");
}
// Complete the batch of changes
collectionController.endChangeSet();
// Call the coordination completion method
ControllerManager.unbind(editable);
complete();
});
// Handler for AFTERLOADWIDGET topic
coordination.participate(Constants.CoordTopic.AFTERLOADWIDGET, function(context, complete, abort) {
// Release the controller binding
//ControllerManager.unbind(editable);
complete();
});
});
------------------------------
BAW User
------------------------------