Calling a script include from UI Action - Workspace Client Script

PontusL
Tera Contributor

Hi

 

I have a quite simple UI Action:

function confirmReservation() {
var taskSysId = g_form.getUniqueValue();

var reservationNumber = prompt("Please enter the reservation number:");
if (reservationNumber != null && reservationNumber.trim() !== "") {
var ga = new GlideAjax('ConfirmReservationAjax');
ga.addParam('sys_id', taskSysId);
ga.addParam('reservation_number', reservationNumber);
ga.addParam('sysparm_name', 'confirmReservation');
ga.getXMLAnswer(function(response) {
var answer = response;
if (answer == 'success') {
g_form.addInfoMessage("Reservation confirmed and task state updated.");
g_form.save();
} else {
g_form.addErrorMessage(answer);
}
});
} else {
g_form.addErrorMessage("Reservation number was not provided, please provide the reservation number.");
}
}

It is working perfectly fine, however I want this to be functoning in the Workspace as well. So I have copied the code to the "Workplace Client Script" but the script include is never called. I have logged it and it breaks at the line "ga.getXMLAnswer(function(response))
PontusL_0-1725706311296.png

Does anyone have any idea on why, or possibly any knowledge about how to call the script include for the workspace in another way?

4 REPLIES 4

debendudas
Mega Sage

Hi @PontusL ,

Please update your script include's 'Accessible from' field value from 'This application scope only' to 'All application scopes'.

 

If this solution helps you then, mark it as accepted solution ‌‌✔️ and give thumbs up 👍

Hi @debendudas ,

It is set to "all application scopes", it is also working on the "normal" UI action script, just not on the workspace client script

Hi @debendudas ,

 

Thank you for the reply. I have that set to 'All application scopes', it is also running in the back-end calling the script include from the "normal" UI Action, which is the same script. The issue is when I try to call it from the Workspace Client script, it will not access the script include.

David Rosevold1
Tera Contributor

Perhaps you can add 'isPublic' at the beginning of your script include.   For example:

var GlideAjaxDR = Class.create();
GlideAjaxDR.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	isPublic:function(){return true; },
	
	getUserInfo: function(){

or

https://www.servicenow.com/community/developer-forum/required-permissions-for-server-script-includes...