How to avoid DOM manipulation in UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 06:26 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 01:19 AM
This also is giving the same error while scanning
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 01:34 AM
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();
}