var currentWorkitem = payload.workItemEditable;
var currentCase = currentWorkitem.getCase();
var selectedResponse = currentWorkitem.getSelectedResponse();
if (selectedResponse == "Forward")
{
addCommentToCase(currentCase,"Selected response:"+selectedResponse);
showPrintPopup(currentCase,selectedResponse,["CmAcmCaseIdentifier",
"JNP_SampleProperty","JNP_OtherProperty","Creator","DateCreated"]);
}
else
{
var a;
a = alert("You Pressed: "+selectedResponse);
addCommentToCase(currentCase,"Selected response:"+selectedResponse);
}
function addCommentToCase(currentCase,text){
currentCase.addCaseComment(102,text,function onReady(){
console.log("comment was set!");
},function onFailure(){
console.error("could not create case comment")
},true);
}
function showPrintPopup(currentCase, selectedResponse, propertiesToPrint){
new_window = window.open("ibm_case_manager.html");
var someHTML="";
var print;
var d = new Date();
for (var i=0; i< propertiesToPrint.length;i++){
var property1 = propertiesToPrint[0];
var CaseID= currentCase.getValue(property1);
var property2 = propertiesToPrint[1];
var SampleProp= currentCase.getValue(property2);
var property3 = propertiesToPrint[2];
var OtherProp= currentCase.getValue(property3);
var property4 = propertiesToPrint[3];
var CreatedBy= currentCase.getValue(property4);
var property5 = propertiesToPrint[4];
var DateC= currentCase.getValue(property5);
}
new_window.document.write('
');
new_window.document.write('');
new_window.document.write('Date: '+DateC+' | ');
new_window.document.write('
');
new_window.document.write('
');
new_window.document.write('');
new_window.document.write('');
new_window.document.write('');
new_window.document.write('');
new_window.document.write('CSO ID: '+CreatedBy+' | ');
new_window.document.write('');
new_window.document.write('');
new_window.document.write('Case Type: Test Case | ');
new_window.document.write(' ');
new_window.document.write(' ');
new_window.document.write(' |
');
new_window.document.write('');
new_window.document.write('');
new_window.document.write('');
new_window.document.write('');
new_window.document.write('');
new_window.document.write(''+CaseID+' | ');
new_window.document.write(''+SampleProp+' | ');
new_window.document.write(''+OtherProp+' | ');
new_window.document.write(' ');
new_window.document.write(' ');
new_window.document.write(' |
');
}
return payload;