Validate before sent work item
Add a Script Adaptor widget to the hidden widgets area on a work details pageWire 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.
============Code java script =============
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();
}
});
}
});
Không có nhận xét nào:
Đăng nhận xét