Thứ Năm, 15 tháng 9, 2016

Displaying Related Cases in ICM 5.2 

I described how you could use the Case List widget to display a list of "Related Cases"; cases that are somehow related to the case you are currently looking at.
This has been a pretty popular solution customization so I thought it was about time I updated it for ICM 5.2.x.






The use case here is that you want to display a list of related cases on a work details page that is used to process a task step for a particular case. You can easily modify the first bit if your Case List happens to be on another page (eg. payload.caseEditable.
  • Add a case list widget to your Work Details page
  • Use the wiring settings to disable the Select Case broadcast event. This ensures the case list does not interfere with other page widgets like the Case Infomation
  • Add a Script Adapter widget to the hidden page area
  • Enter the following script in the Script Adapter
  • Wire the inbound event of the Script adapter from the Page Container's "send Work Item" event
  • We use a broadcast event in our script so no need to wire the outbound event
var solution = this.solution;
var params = {};
var self = this;

/* This is good practice. Makes reusing scripts much easier */
var prefix = solution.prefix;

params.ObjectStore = solution.getTargetOS().id;

var custID = payload.workItemEditable.propertiesCollection[prefix+"_CustomerID"].value;
console.log ("Customer ID: ",custID);

var caseObj = payload.workItemEditable.icmWorkItem.caseObject;

/^ The following call ensures that the case data is loaded before we go try and get the case ID */

caseObj.retrieveCachedAttributes(function(caseObject) {
    var caseID = caseObject.caseIdentifier;
    console.log ("Case ID: ",caseID);

    /* Find all of these */
var criterion1 = new ecm.model.SearchCriterion({"id": prefix+"_CustomerID", 
"name" : "Customer ID", 
        "selectedOperator": "STARTSWITH", "defaultOperator": "STARTSWITH",
 "dataType": "xs:string"});
    criterion1.value = custID ;
    criterion1.defaultValue = custID ;
    criterion1.setValues( [custID]);

    /* But omit this one */
    var criterion2 = new ecm.model.SearchCriterion({"id": "cmAcmCaseIdentifier", "name" : "Title",
 "anded": true,
 "selectedOperator": "NOTEQUAL", "defaultOperator": "NOTEQUAL", 
"dataType": "xs:string"});
    criterion2.value = caseID;
    criterion2.defaultValue = caseID;
    criterion2.setValues( [caseID]);

    params.criterions = [criterion1, criterion2];
    params.CaseType = ""; /* all case types */
    params.solution = solution;

    var searchPayload = new icm.util.SearchPayload();
    searchPayload.setModel(params);

    searchPayload.getSearchPayload(function(payload) {
        self.onBroadcastEvent("icm.SearchCases", payload);
    });
});






 

Không có nhận xét nào:

Đăng nhận xét