Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to avoid DOM manipulation in UI action

Roshini
Giga Guru

Hi Team,
For the below code am getting DOM manipulation warning in update set scanning.
Am trying to call a view via the glideDialogForm, is there any alternations can be done for fixing the dom manipulation error.


function onHoldAction() {

     var sysid = g_form.getUniqueValue();
    var dialog = new GlideDialogForm('ON Hold', 'incident'); //Provide dialog title and table name
    dialog.setSysID(sysid);
    dialog.addParm('sysparm_view', 'on_hold_dialog_view');
    dialog.addParm('sysparm_form_only', 'true');
    dialog.render(); //Open the dialog
}
6 REPLIES 6

This also is giving the same error while scanning

AbdulNow
Tera Guru

Hi @Roshini I hope you are doing well, I suggest Use GlideModal instead of GlideDialogForm: GlideModal is a more modern, recommended approach for displaying modals and forms. It offers better compatibility with ServiceNow UI policies and avoids common issues with direct DOM manipulation.

 

Please refer below code as a sample

 

function onHoldAction() {
    var sysid = g_form.getUniqueValue();
    
    // Using GlideModal for better compatibility
    var dialog = new GlideModal('incident', false); // 'incident' is the table name
    dialog.setTitle('ON Hold'); // Set the dialog title
    
    // Set the Sys ID of the record that needs to be viewed or edited
    dialog.setPreference('sys_id', sysid);
    dialog.setPreference('sysparm_view', 'on_hold_dialog_view');
    dialog.setPreference('sysparm_form_only', 'true');
    
    // Render the dialog
    dialog.render();
}