- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-30-2023 09:20 AM
Hi,
I am trying to add server side script inside "workspace client script" whenever user clicks on the UI button on the workspace, Popup should appear Clicking on "Yes" all the related task should close based on the confirmation.
I have checked on Client callable and Format for Configurable Workspace to true.
and it is scoped application.
Below is my script, Please help me to get this working.
Workspace client script:
function onClick(g_form) {
var taskId = g_form.getUniqueValue();
var msg = getMessage("Are you sure you want to take this action?");
g_modal.confirm(getMessage("Confirmation"), msg, function(confirmed) {
if (confirmed) {
var a = new GlideAjax('sn_audit.calltask');
a.addParam('sysparm_name', "StateOfRisk");
a.addParam('sysparm_id', taskId);
}
a.getXML(copyParse);
function copyParse(response)
{
var resultMessage = response.responseXML.documentElement.getAttribute("answer");
}});
Script Include:
var calltask = Class.create();
calltask.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
StateOfRisk: function() {
var sys_id = this.getParameter('sysparm_id');
var gr = new GlideRecord("sn_audit_task");
gr.addQuery('parent',sys_id);
gr.query();
while(gr.next()){
gr.state = 7;
gr.update();
}
},
type: 'calltask'
});
It's not calling the script include , I checked by adding the logs. Please help me to know where I'm going wrong.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-03-2023 07:31 AM
try this
function onClick(g_form) {
var msg = getMessage("Are you sure you want to take this action?");
g_modal.confirm(getMessage("Confirmation"), msg).then(function onSuccess() {
var taskId = g_form.getUniqueValue();
var a = new GlideAjax('sn_audit.calltask');
a.addParam('sysparm_name', "StateOfRisk");
a.addParam('sysparm_id', taskId);
a.getXMLAnswer(copyParse);
});
function copyParse(response)
{
// do nothing
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-03-2023 09:50 AM
I am not understanding why my script include is not getting called when I click on UI action
Please help me on this to make it work