Ui Action not working in Workspace
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
15m ago
Below code for Workspace Client Script not working:
Requirement: If parent case contain open child tasks, while closing the case it will show a pop-up and close parent along with child
function onClick() {
if (!g_form.getValue("assigned_to")) {
g_form.addErrorMessage('Assigned To cannot be empty. Please fill the Assign To field before moving the request to Awaiting Info or Resolved.');
return false;
}
var close_notes = g_form.getValue("close_notes");
var resolution_code = g_form.getValue("resolution_code");
//var cause1 = g_form.getValue("cause");
if (!close_notes || !resolution_code) {
g_form.addErrorMessage(
getMessage(
'To propose a solution, you must select a resolution code and add resolution notes.'
)
);
return false;
}
// First check if there are open tasks
gaCheck = new GlideAjax("sn_customerservice.CheckTaskRecord");
gaCheck.addParam('sysparm_name', 'checkIfTask');
gaCheck.addParam('sysparm_request_id', g_form.getUniqueValue());
g_form.addInfoMessage(g_form.getUniqueValue());
gaCheck.getXMLAnswer(function(response) {
g_form.addInfoMessage("Test2");
var tasksAvailable = response;
if (tasksAvailable == true) {
g_form.addInfoMessage("Test1");
if (!confirm("Resolution of request will close all open tasks. Do you want to proceed?")) {
return;
} else {
gaCheck = new GlideAjax("sn_customerservice.CheckTaskRecord");
gaCheck.addParam('sysparm_name', 'updateTaskRecord');
gaCheck.addParam('sysparm_request_id', g_form.getUniqueValue());
gaCheck.getXMLAnswer(function(response) {
var res = response;
});
}
}
g_form.setValue("state", "6");
g_form.update();
});
}var CheckTaskRecord = Class.create();
CheckTaskRecord.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkIfTask: function() {
var parent = this.getParameter('sysparm_request_id');
var taskGR = new GlideRecord("sn_customerservice_task");
taskGR.addQuery("parent_case", parent);
taskGR.addQuery("state", "!=", "3");
taskGR.query();
if (taskGR.hasNext())
return true;
else
return false;
},
updateTaskRecord: function() {
var parent = this.getParameter('sysparm_request_id');
var taskGR = new GlideRecord("sn_customerservice_task");
taskGR.addQuery("parent_case", parent);
taskGR.addQuery("state", "!=", "3");
taskGR.query();
while (taskGR.hasNext()) {
taskGR.setValue("state", "3");
taskGR.setValue("work_notes", "Parent request has been resolved.");
taskGR.update();
}
return true;
},
type: 'CheckTaskRecord'
});
0 REPLIES 0