Console error: ReadOnly true not set on field : cross scope access denied Reservation Management

Raj_Esh
Kilo Sage
Kilo Sage

Heyllo All,

 

I have created UI Action on Reservation form - "Cancel Series" (client = true) with below code to allow admin to cancel parent Reservation and related child reservations from backend and also set the value of field "canceling series" to true on the parent form, as this triggers the series cancellation notification, but the script does not set the value of this field and throws the error as shown in screenshot, has someone faced such issue before. The scope which I am currently implementing is in Workplace Reservation management, hoping it is not related to it and also there is no cross-scope access is created to allow access for scopes.

 

Ui Action :


function ValidateCancelNote() {

var note = g_form.getValue('cancel_notes');
if (!note) {
g_form.setMandatory('cancel_notes', true);
} else {
var ga = new GlideAjax('WSDSeriesCancel');
ga.addParam('sysparm_name', 'cancelSeriesReservation');
ga.addParam('sysparm_reserve', g_form.getUniqueValue());
ga.addParam('sysparm_note', note);
ga.getXMLAnswer(function(response) {
var result = JSON.parse(response);

if (result.status === 'success') {
g_form.addInfoMessage(result.message);
g_form.setReadOnly('cancel_notes', true);
g_form.setValue('canceling_series', true);
} else {
g_form.addErrorMessage(result.message);
}
});
}
}

 

Script include :


cancelSeriesReservation: function() {
var result = {
status: "success",
message: gs.getMessage("This reservation was canceled")
};
var reservationId = this.getParameter('sysparm_reserve');
var cancelnote = this.getParameter('sysparm_note');
var res_gr = new GlideRecord(WPConstants.TABLES.RESERVATION);
res_gr.addQuery('sys_id', reservationId).addOrCondition('source_reservation', reservationId);
res_gr.addQuery('state', WPConstants.RESERVATION_STATE.CONFIRMED);
res_gr.addQuery('active', true);
res_gr.orderByDesc('number'); //to cancel children first
res_gr.query();

var childrenCancelationSuccessful = true;

while (res_gr.next()) {
if (!gs.nil(res_gr.source_reservation)) {
if (res_gr.canWrite() || (gs.hasRole("sn_wsd_core.workplace_user") && res_gr.workplace_request.opened_by == gs.getUserID())) {
res_gr.setValue('state', 'cancelled');
res_gr.setValue('active', false);
res_gr.setValue('cancel_notes', cancelnote);
WSDRecurringReservationServiceSNC.setCancelingSeriesFieldToTrue(res_gr);
res_gr.update();
} else
childrenCancelationSuccessful = false;
} else {
if (childrenCancelationSuccessful && res_gr.canWrite() || (gs.hasRole("sn_wsd_core.workplace_user") && res_gr.workplace_request.opened_by == gs.getUserID())) {
res_gr.setValue('state', WPConstants.RESERVATION_STATE.CANCELLED);
res_gr.setValue('active', false);
res_gr.setValue('cancel_notes', cancelnote);
WSDRecurringReservationServiceSNC.setCancelingSeriesFieldToTrue(res_gr);
res_gr.update();
} else {
result.status = "error";
result.message = gs.getMessage("We were unable to cancel this reservation. Contact your system administrator for details.");
}
}
}
return JSON.stringify(result);
},

 

When clicking on UI Action , the value seems set to True, but when the form is reloaded it is false. Attached screenshot with console error log.

 

 

Raj_Esh_0-1745497822660.png

 

Thank you for the hint or the help.

 

--Raj
2 REPLIES 2

Voona Rohila
Kilo Patron
Kilo Patron

@Raj_Esh 

So 'cancel_notes' field is not being set to ReadOnly onLoad of form right?

 

The ReadOnly in your UI Action is only set when you click the button.Can you please share the Ui Policy/Client Script that is making the field readonly?

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Ankur Bawiskar
Tera Patron
Tera Patron

@Raj_Esh 

so did you check what value it shows in XML?

If it's true it means your UI action updated it fine but some other script etc is making it false again when form loads

Did you debug that?

Is that field in same scope as that of the UI action?

what's your field name? is it the same shown in console error?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader