IBM Support

Solution to validate work item datafield by responseName

Technical Blog Post


Abstract

Solution to validate work item datafield by responseName

Body

Solution to validate work item datafield by responseName
Author: Gai Li(
ligai@cn.ibm.com)
This document introduces one way that user can interrupt the ICM work item datafields validation and insert the customized validation mechanism.

Requirement:
User want to validate case data by responseName when dispatch work item. If the validation pass, work item will be dispatched. Otherwise, a warning message alerts and work item will not be dispatched.

Steps for Solution:
1. On the Work Item Detail page, add a Script Adapter widget named "get responseName", wire it to receive "Complete work item" event from WorkItem Toolbar widget. In the Javascript codes, save the response name to a global variable;
     var responseName = payload.responseName;
     dojo.setObject("currentItem.responseName", responseName);

image  
 
 
 
 
 

2. On edit setting of Case Data widget, disable the broadcasting event "Respond poll work item data update" event.

image  
 
 
 
 
 
 
 
 
 
 
 

3. Add another Javascript Adapter named "validate dataFields", wire it to receive "Response Poll Work Item Update" from Case Data widget. And wire it to send "Response Poll Work Item Update" event to Command Widget. Users can insert logic in this javascript adapter to validate data fields.
    if(currentItem.responseName == "Review"){
      //Some codes to do validation.
      //If datafields validation successes, pass.
      //If datafields validation fails, update payload. With stateCode=4, Command widget will not dispatch work item; With hideMessage = true, Command widget will mute.
      //Sample for update payload:  payload.stateCode = 4; payload.hideMessage=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

ibm11281784