GlideAjax blocked from Script Include in same scope despite Isolate Script enabled
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi all,
I'm working within the Security Incident Response (SIR) application scope (sn_si) and trying to trigger a Script Include via a client-side UI Action using GlideAjax.
The setup:
- The UI Action and Script Include are both in the sn_si scope
- The Script Include is Client Callable as per the enabled field.
- The UI Action has Isolate Script enabled
- UI Action spits out a warning with:
"Access to Script Include sn_si.SIR_to_CSIS_conversion_UI_Action blocked from scope: sn_si"
I understand that GlideAjax requires the Script Include to be client-callable, but since both components are in the same scope, I expected this to work, especially with Isolate Script enabled.
My Script Include:
var SIR_to_CSIS_conversion_UI_Action = Class.create();
SIR_to_CSIS_conversion_UI_Action.prototype = {
initialize: function() {},
createFromSIR: function() {
var sirSysId = this.getParameter('sysparm_sirSysId');
var result = { success: false, message: '', newRequestId: '' };
var sourceGR = new GlideRecord('table_a');
if (!sourceGR.get(sirSysId)) {
result.message = 'Source record not found.';
return JSON.stringify(result);
}
if (!gs.nil(sourceGR.u_linked_record)) {
result.message = 'A related record has already been created.';
return JSON.stringify(result);
}
var targetGR = new GlideRecord('table_b');
targetGR.initialize();
targetGR.description = 'Created from source ' + sourceGR.getDisplayValue('number');
targetGR.setValue('u_field_1', 'value_1');
targetGR.setValue('u_field_2', 'value_2');
targetGR.setValue('u_field_3', 'value_3');
var newId = targetGR.insert();
if (!newId) {
result.message = 'Failed to create the new record.';
return JSON.stringify(result);
}
// Copy latest work note
var journalGR = new GlideRecord('sys_journal_field');
journalGR.addQuery('element_id', sourceGR.getUniqueValue());
journalGR.addQuery('element', 'work_notes');
journalGR.orderByDesc('sys_created_on');
journalGR.setLimit(1);
journalGR.query();
if (journalGR.next()) {
var latestNote = journalGR.getValue('value');
var noteUpdateGR = new GlideRecord('table_b');
if (noteUpdateGR.get(newId)) {
noteUpdateGR.work_notes = latestNote;
noteUpdateGR.update();
}
}
// Update assigned_to
var finalUpdateGR = new GlideRecord('table_b');
if (finalUpdateGR.get(newId)) {
finalUpdateGR.setValue('assigned_to', sourceGR.getValue('assigned_to'));
finalUpdateGR.update();
}
// Link source to new record
sourceGR.u_linked_record = newId;
sourceGR.update();
result.success = true;
result.newRequestId = newId;
return JSON.stringify(result);
},
type: 'SIR_to_CSIS_conversion_UI_Action'
};
My UI Action:
function createCSISRequestFromSIR() {
var ga = new GlideAjax('sn_si.SIR_to_CSIS_conversion_UI_Action');
ga.addParam('sysparm_name', 'createFromSIR');
ga.addParam('sysparm_sirSysId', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
try {
var result = JSON.parse(response);
if (result.success) {
window.location.href = '/table_b.do?sys_id=' + result.newRequestId;
} else {
g_form.addErrorMessage(result.message || 'An error occurred while creating the CSIS request.');
}
} catch (e) {
g_form.addErrorMessage('Unexpected error occurred.');
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
make the new script include as Accessible from "Application scopes" and then try calling
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
yesterday
@Ankur Bawiskar This is already the case for the script include I newly created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Please raise a case with ServiceNow.
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
yesterday
Thank you for giving your time to take a look