UI action in wokspace
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14m ago
I want to show a pop-up if there are related tasks before closing the parent case.
The below code is working for native UI but how to add the same functionality in workspace? Need the same feature of "global.StateFlow().processFlow" in workspace as well.
function runClientCode() {
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 gaCheck = new GlideAjax("sn_customerservice.CheckTaskRecord");
gaCheck.addParam('sysparm_name', 'checkIfTask');
gaCheck.addParam('sysparm_request_id', g_form.getUniqueValue());
gaCheck.getXMLAnswer(function(response) {
if (response == "1") {
if (confirm("Resolution of request will close all open tasks. Do you want to proceed?")) {
var gaResolve = new GlideAjax("sn_customerservice.CheckTaskRecord");
gaResolve.addParam('sysparm_name', 'closeTaskRecord');
gaResolve.addParam('sysparm_request_id', g_form.getUniqueValue());
gaResolve.getXMLAnswer(function(answer) {
if (answer == "1") {
g_form.addInfoMessage("test4");
gsftSubmit(null, g_form.getFormElement(), 'proposeSolution');
}
});
} else
return false;
} else
gsftSubmit(null, g_form.getFormElement(), 'proposeSolution');
});
}
if (typeof window == 'undefined') {
runServerCode();
}
function runServerCode() {
new global.StateFlow().processFlow(current, 'sys_id', 'manual');
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2m ago
Ensure these 2 checkboxes are selected and add script in workspace client script
You can check OOTB UI actions and add the code accordingly
Something like this in workspace client script
function onClick(g_form) {
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 gaCheck = new GlideAjax("sn_customerservice.CheckTaskRecord");
gaCheck.addParam('sysparm_name', 'checkIfTask');
gaCheck.addParam('sysparm_request_id', g_form.getUniqueValue());
gaCheck.getXMLAnswer(function(response) {
if (response == "1") {
if (confirm("Resolution of request will close all open tasks. Do you want to proceed?")) {
var gaResolve = new GlideAjax("sn_customerservice.CheckTaskRecord");
gaResolve.addParam('sysparm_name', 'closeTaskRecord');
gaResolve.addParam('sysparm_request_id', g_form.getUniqueValue());
gaResolve.getXMLAnswer(function(answer) {
if (answer == "1") {
g_form.addInfoMessage("test4");
g_form.submit('proposeSolution');
}
});
} else
return false;
} else
g_form.submit('proposeSolution');
});
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader