Is it possible to show Modal in List View in Classic UI?

Mustafa6
ServiceNow Employee
ServiceNow Employee

Pretty much the Subject. Can we show custom Modal (or even a simple Yes/No Modal) in List view in Classic 16?

1 REPLY 1

Siddhesh Jadhav
Kilo Sage

Hello @Mustafa6 ,

Yes, it is possible to show a custom modal (like a Yes/No or informational dialog) in List view using a onCellEdit Client Script.


Solution:

Ensure that the "Isolate Script" flag is unchecked in the client script configuration. This is required so that the script can access and manipulate the DOM to display the modal.

Use the following onCellEdit client script to display a modal when a specific field is edited and prevent the list edit from being saved:

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
	try {
		if (newValue) {
			// Show modal message and prevent save
			cancelDialog(function () {
				callback(false); // Don't save list edit
			});
		}
	} catch (err) {
		console.error('Error in onCellEdit client script: ' + err.message);
		callback(false);
	}
}

function cancelDialog(callback) {
	var dialog = new GlideModal();
	dialog.setTitle('Action Not Allowed');

	// Assign unique callback to window scope
	window.__dialogCallback = function () {
		dialog.destroy(); // Close the modal
		callback();       // Notify to stop list edit
		delete window.__dialogCallback; // Clean up
	};

	dialog.renderWithContent(
		'<div style="padding:20px; font-size:14px;">' +
		'<p><strong>Lifecycle State</strong> and <strong>Lifecycle Stage Status</strong> must be updated together from the form. List editing is not allowed.</p>' +
		'<div style="text-align:right; margin-top:20px;">' +
		'<button class="btn btn-primary" onclick="window.__dialogCallback()">OK</button>' +
		'</div>' +
		'</div>'
	);
}

I implemented this approach to prevent inline editing of lifecycle-related fields on the Asset, Contract, and Install Base Item tables. It provides a cleaner user experience and enforces data integrity by requiring users to update related fields together from the form.


If this helps resolve your query, please accept the answer and mark it as helpful.

Best Regards,
Siddhesh Jadhav

SiddheshJadhav_0-1750337201015.pngSiddheshJadhav_1-1750337235133.pngSiddheshJadhav_2-1750337266399.png