- 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 07:40 AM
I tried with the provided solution but still not calling script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-03-2023 08:01 AM
@Ankur Bawiskar
Till function call info message is getting displayed , facing issue after function call which is not getting inside the function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-03-2023 08:51 AM
so are you saying you are not getting info message within the callback method?
but is it updating the record as per script include function? If yes then you need not worry
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:44 AM
No, it is not updating the form
I do not see any logs on script Include
It is not call my script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-03-2023 10:07 PM
don't add gs.log() as it won't work in scoped app
use gs.info()
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader