I'm trying to preview similar IBM Case manager cases when a case is opened, I'm getting error onBroadcastEvent is not a function it is not included inside self. I'm using wiring to the script adapter (send work Item)
require(["icm/model/properties/controller/ControllerManager", "ecm/model/Desktop" ], function(ControllerManager, Desktop) {
var solution = Desktop.currentSolution;
var params = {};
var self = this;
var prefix = solution.prefix;
params.ObjectStore = solution.getTargetOS().id;
var custID = payload.workItemEditable.propertiesCollection.LSS_IdentificationValue.value;
console.log ("Customer ID: ",custID);
var caseObj = payload.workItemEditable.icmWorkItem.caseObject;
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+"IdentificationValue", "name" : "Identification Type", "selectedOperator": "STARTSWITH", "defaultOperator": "STARTSWITH", "dataType": "xs:string"});
criterion1.value = custID ;
criterion1.defaultValue = custID ;
criterion1.setValues( [custID]);
params.criterions = [criterion1];
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);
});
});
});
Your "this" in "var self = this;" resides in an anonymous function, therefore this is probably the Window object.
Do i understand correctly that this code-block is in a scriptadapter? In that case, move your assignment to the first line, before your require. Then your self will the the scriptadapter (that has the onBroadcastEvent function on it).