BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  IBM Case Manager script adapter, update and save property

    Posted Mon September 09, 2024 12:54 PM

    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 as a wiring.

    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();
       });
    });


    ------------------------------
    Amina SAHLAOUI
    ------------------------------


  • 2.  RE: IBM Case Manager script adapter, update and save property

    Posted Wed September 11, 2024 04:55 AM

    Hi,

    Try something like this after you have set the property:

    var actionContext = {
        "WorkItemPage" : [ payload.workItemEditable ],
        "Coordination" : [ payload.coordination ],
        "UIState" : [ payload.UIState ]
    };
    icm.action.Action.perform(this, "icm.action.workitem.SaveWorkItemOnPage", actionContext);

    For reference: icm.action - IBM Documentation

    Good luck!

    Dave.



    ------------------------------
    Dave Ward
    ------------------------------



  • 3.  RE: IBM Case Manager script adapter, update and save property

    Posted Thu September 12, 2024 04:18 AM

    It works great.

    Thank you Dave !



    ------------------------------
    BAW User
    ------------------------------