Dom manupaulation

SravyaA
Tera Contributor

Hello All,

 

We have one catalog client script which uses dom manipulation.

 

function onSubmit() {

    //var checkValueOfField = g_form.getValue('u_select_user_profile');

    // check CT or ITP access is contained within the variable
    //if (checkValueOfField.indexOf('d03dd507db1d3f40034de0a1ca96196c')>=0 || checkValueOfField.indexOf('1a3dd507db1d3f40034de0a1ca96199e')>=0){


    //run attachment check
    if (g_form.getValue('type_request') == "inquiry") {

        if ((this.document.getElementsByClassName('get-attachment').length == 0)) {

            // no attachment uploaded, we alert user and dont submit request

            alert('Attachment (screenshot of error) is mandatory for incident submission.');

            return false;


        }
    }
}

It is not working as excepted. We  identified that Dom manipulation is not working on current ServiceNow version .
:
SravyaA_0-1733379618701.png

 

Based on the below link:
We made isolated script to false and created the property which mentioned in the article but the issue remains same. 
 
Please do need full help.
 
Regards,
sravya.A
10 REPLIES 10

Chaitanya ILCR
Kilo Patron

Hi @SravyaA ,

try this out with isolate script =false

function onSubmit() {

    //var checkValueOfField = g_form.getValue('u_select_user_profile');

    // check CT or ITP access is contained within the variable
    //if (checkValueOfField.indexOf('d03dd507db1d3f40034de0a1ca96196c')>=0 || checkValueOfField.indexOf('1a3dd507db1d3f40034de0a1ca96199e')>=0){


    //run attachment check
    if (g_form.getValue('type_request') == "inquiry") {

        if ((document.getElementsByClassName('get-attachment').length == 0)) {

            // no attachment uploaded, we alert user and dont submit request

            alert('Attachment (screenshot of error) is mandatory for incident submission.');

            return false;


        }
    }
}

  Regards,

Chaitanya

We tried but no use

same error

SravyaA_0-1733385771900.pngSravyaA_1-1733385813149.png

 

Try check "Isolate script"

From Docs;

Isolate scriptNew client scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype, and the window object are also disabled. To disable this on a per-script basis, configure this form and select the Isolate script check box. To disable this feature for all new globally-scoped client-side scripts set the system property glide.script.block.client.globals to false.

We tried to check the isolate script check box .it shows the same error as above mentioned.