window.myPayload = payload;
window.solutionPrefix= this.solution.getPrefix();
var editable = myPayload.caseEditable;
alert(editable);
if(editable != null){
require(['icm/model/properties/controller/ControllerManager'],
function(ControllerManager) {
var collectionController = ControllerManager.bind(editable);
collectionController.beginChangeSet();
//Get Current User Name
var PortEmployeeName = ecm.model.desktop.userDisplayName;
//Set as default value for textbox PortEmployeeName
collectionController.getPropertyController(solutionPrefix + '_PortEmployeeName').set('value',PortEmployeeName);
collectionController.endChangeSet();
ControllerManager.unbind(editable);
});
}
Show Hide field based on another field value
var solution = this.solution;
var prefix = solution.getPrefix();
require([ "icm/model/properties/controller/ControllerManager"]
, function( ControllerManager)
{
workItem = payload.workItemEditable;
this.collectionController = ControllerManager.bind(workItem);
this.collectionController.getPropertyController(prefix+"_PROJECTMILESTONDATES").watch("value", function(value){
if (value === "1"){
collectionController.getPropertyController(prefix+"_REVIEWUSERS").set("hidden", true);
} else {
collectionController.getPropertyController(prefix+"_REVIEWUSERS").set("hidden", false);
}
});
});
Add button beside textbox
search for textbox that has placeholder = "project_name" and add button beside it
dojo.query("input[placeholder='project_name']").forEach(function(item)
{
item.offsetParent.offsetParent.insertAdjacentHTML('beforeend', "<input type=button value=? class=btn >");
});
Add Case Custom validation before save
- // 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();
}
});
}
});
Workitem data validation
based on which step response is selected
- 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();
}
});
}
});
Hiding Attachment widget based on some property
//var coord = payload.coordination;
//var caseEdit = payload.caseEditable;
//var solution = this.solution;
//var prefix = solution.getPrefix();
if (payload.eventName === "icm.SendWorkItem" )
{
var coordination = payload.coordination;
var workEdit = payload.workItemEditable;
if(workEdit.icmWorkItem.stepName === "Request for PreSubmission Meeting")
{
require(["icm/model/properties/controller/ControllerManager", "icm/base/Constants","ecm/model/Repository"],function(ControllerManager, Constants,repository)
{
coordination.participate(Constants.CoordTopic.AFTERLOADWIDGET, function(context, complete, abort)
{
var collectionController = ControllerManager.bind(workEdit);
var Controller = collectionController.getPropertyController("CPA_VarHideAttachment"); // CPA_VarHideAttachment Case property
var HideAttachment = Controller.get("value");
if(HideAttachment == "Yes")
{
dojo.query("span").forEach(function(item)
{
if(item.innerHTML==="Attachments")
{
var prnt = item.parentNode.parentNode.parentNode.parentNode.parentNode;
prnt.style.display = "none";
}
});
}
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. */
coordination.participate(Constants.CoordTopic.AFTERLOADWIDGET, function(context, complete, abort) {
/* Release the controller binding for the editable. */
ControllerManager.unbind(workEdit);
/* Call the coordination completion method. */
complete();
});
});
}
}