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

jusfory1
Tera Expert

You can't access dom by the key word 'document' directly as this code snapt revoled in js sandbox, but can get access dom by this methoed

var form_field_name='';//like number or state anything else;
var rootEle = g_form.getElement(form_field_name).getRootNode();// DOM;