IBM Support

ICM Data Validation When Adding New Cases

Technical Blog Post


Abstract

ICM Data Validation When Adding New Cases

Body

In a previous blog entry I showed how to use ICM 5.2's new coordination mechanism to hook in custom logic when saving and closing any of the transient pages such as step complete.

In this entry, I have modified the example to show how to do the same thing on the Add Case page.

  • Add a Script Adapter to your Add Case page and hide it
  • Wire the incoming event for the Script Adapter from the Page Container's Send New Case Information event


var coord = payload.coordination;
var caseEdit = payload.caseEditable;
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 coordination step*/

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

if(context[Constants.CoordContext.CASE]){

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

   var propId = prefix + '_Description';

   /*Retrieve prop value(s) using property controller API*/

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

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

   ControllerManager.unbind(caseEdit);

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

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

      abort({"message":"Please enter a description before adding the case."});
   }else{
      complete();
   }
 }else{
    complete();
 }
 });
}
});

For more information on the coordination mechanism, search for coordination in the ICM Javascript API InfoCenter chapters.

 

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

UID

ibm11281292