IBM Support

How do I dynamically add choices to a case property displayed in the Properties widget on a Add Task page?

Technical Blog Post


Abstract

How do I dynamically add choices to a case property displayed in the Properties widget on a Add Task page?

Body

 

IBM Case Manager already provides several ways of associating choice lists with case properties. This includes directly assigning them in case builder or indirectly adding them using ICM's External Data Services (EDS).

If you like doing client-side scripting, here is another way to leverage ICM 5.2's new JavaScript model. You can also assign choice lists to workflow data fields using this technique (just use the data field name without appending the solution prefix).

  • Wire a Script Adaptor to the icm.SendNewTaskInfo event from container.
var theProp = this.solution.getPrefix() +"_CaseStage";

console.log("Registering choice function");

/* For the add task payload, the workItemEditable is returned by the getLaunchStep method */

var workItemEdt = payload.taskEditable.getLaunchStep();
var coord = payload.coordination;

var choices = [{
    label: "Triaging",
    value: "1"
}, {
    label: "Processing",
    value: "2"
}, {
    label: "Finalizing",
    value: "3"
}];

require(["icm/model/properties/controller/ControllerManager", "icm/base/Constants"],function(ControllerManager, Constants){
    coord.participate(Constants.CoordTopic.LOADWIDGET, function(context, complete, abort){
        var propsController = ControllerManager.bind(workItemEdt);
        var propController = propsController.getPropertyController(theProp);
        if (propController){
            propController.set("choices", choices);
        }
        else
            console.log("ERROR - No such property: " + theProp);        
        complete();
    });

   /* Use the AFTERLOADWIDGET coordination topic handler to release the controller binding for the editable. */
   /* Since the prop controller can be shared, doing this in the AFTERLOADWIDGET ensures no other widget overrides your changes. */
   coord.participate(Constants.CoordTopic.AFTERLOADWIDGET, function(context, complete, abort) {
      /* Release the controller binding for the editable. */
      ControllerManager.unbind(editable);

      /* Call the coordination completion method. */
      complete();
   });

});

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSCTJ4","label":"IBM Case Manager"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

UID

ibm11281256