- 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 06:33 AM
I believe your script include is not client callable
Did you check script include is getting called or not?
Also both UI action and script include are in same scope?
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 07:05 AM
My script include is client callable.
No, Actually I added gs.info() in my script include and got to know is not even calling script include.
And both are in same scope.
Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 07:11 AM
share the script include configuration screenshot
Also share UI action workspace client script screenshot for configuration
You should have workspace form button checkbox checked and then write that script there
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 07:23 AM
- 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