IBM Support

How to perform data validation in ICM 5.2 that is based on which step response is selected

Technical Blog Post


Abstract

How to perform data validation in ICM 5.2 that is based on which step response is selected

Body

 

For many case solutions, a common requirement is to have certain step data required when one step response is clicked, but not necessarily for another. A typical extension to that is to have different requirements based upon which step response is clicked. Here's how you can do that in ICM 5.2.

Here is a piece of sample script for the additional check when completing a work item that will be placed in a Script Adapter widget. 
  • Add a Script Adaptor widget to the hidden widgets area on a work details page
  • Wire an inbound event from the Page Container's Send Work Item to the Script Adaptor's Receive Event.
  • The additional data validation logic will be triggered when the appropriate response button is clicked.
var coord = payload.coordination;
var workitemEdit = payload.workItemEditable;
var solution = this.solution;
var prefix = solution.getPrefix();

require(["icm/base/Constants", "icm/model/properties/controller/ControllerManager"], function(Constants, ControllerManager){

if(coord){

/*Participate in the VALIDATE cordination step*/

coord.participate(Constants.CoordTopic.VALIDATE, function(context, complete, abort){

/*Check the specific response, an empty string ("") stands for the Complete button*/

if(context[Constants.CoordContext.WKITEMRESPONSE] === "Investigate"){

   /*Check work item property attribute's value*/

   var propId = prefix + '_Description';

   /*Retrieve prop value using property controller API*/

   var theController = ControllerManager.bind(workitemEdit);
   var propController = theController.getPropertyController(propId);
   var value = propController.get("value");

   /*Unbind is necessary to prevent mem leak.*/

   ControllerManager.unbind(workitemEdit);

   if(value === null || value === undefined || value === ""){

      /*Abort the workitem completion with passing a message to user*/

      abort({"message":"Please enter a description before sending for investigation."});
   }else{
      complete();
   }
 }else{
    complete();
 }
 });
}
});

 

This code uses the icm.util.Coordination class.

 

As pointed out by one of our astute members, with ICM 5.2.1 an extra parameter was added to the abort call that allows you to disable the default message dialog that is displayed. The idea is that you would display your own custom message dialog prior to calling the abort function. Here is an example replacement for abort with ICM 5,2,1.

 

alert("Your custom message here!");
abort({'silent':true});

 

 

[{"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

ibm11280938