RITM Read-Only script - 'Do you want to leave without saving' message

Feasood
Tera Guru

I have implimented a Catalog Client Script that will make all the variables on a RITM and Catalog Tasks read-only once it has been submitted by the user.

The script I used is as follows:

 

Feasood_0-1690149166029.png

This works perfectly fine apart from when the Fulfilment groups go into the RITM and then try to access a Task or leave the page.  When they do this they get a pop-up message saying "Do you want to leave without saving?" when they haven't changed anything.

 

Feasood_1-1690149245409.png

 

Does anyone know a way around this so the message stops popping up when they try and leave the main RITM page?

 

1 ACCEPTED SOLUTION

Feasood
Tera Guru

I have managed to get this working by adding g_form.fieldChanged = false; into my Client Script as per below example:

Feasood_0-1690426252149.png

 

View solution in original post

3 REPLIES 3

Tony Chatfield1
Kilo Patron

Hi, the documentation for setVariablesReadOnly() states.
"The method must be placed in the client script of the table in which the variable editor is added, such as Requested Item [sc_req_item], Incident [incident], and so on."
and I suspect the issue may be that you are applying it as a Catalog Client Script include against a catalog item, and not as a Client Script against a target\end table.

GlideForm | ServiceNow Developers

 

Thanks Tony,

 

I gave this a go and created a Client Script against the sc_req_item table (as below) but got the same result unfortunately.  I have sifted through the documentation and can't find anything that mentions this sort of thing happening.

 

Feasood_0-1690230326340.png

 

Feasood
Tera Guru

I have managed to get this working by adding g_form.fieldChanged = false; into my Client Script as per below example:

Feasood_0-1690426252149.png