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
when you create a client callable script include it creates a ACL for that.
what role is present there?
try to give public role and see
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
Hi @Ankur Bawiskar
The role in the ACL is sn_si.basic. I am unable to change the roles in this existing ACLDo note I have simply created a new Script Include with the same script albeit with a different Name (and therefore API Name)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
is it not working even with admin?
If yes then try creating a fresh script include and see with that
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 I run the UI action from a user with admin privileges. And unfortunately, creating a fresh Script Include still results in same error message