- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2025 10:46 AM
when some one changes the operational status when install status is installed it has to restrict operational status. And pop up the alert message. It has to work only when we try to change operational to other state. Can anyone help on this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2025 03:35 PM
Hello @SaitejaN ,
I tried and got a Client Script and Script include to work. I am using records in the 'cmdb_ci' table to test.
Client script:
Script:
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
//Type appropriate comment here, and begin script below
var saveAndClose = true;
var validateData = new GlideAjax('MyCMDBUtils');
validateData.addParam('sysparm_name', 'checkInstallStatus');
validateData.addParam('sysparm_ids', sysIDs);
validateData.addParam('sysparm_opstat', newValue);
validateData.getXMLWait();
if (validateData.getAnswer() === 'false') {
alert("Operational Status may not be changed for Installed configuration item");
saveAndClose = false;
}
callback(saveAndClose);
}
The script include is needed to access the record:
Script:
var MyCMDBUtils = Class.create();
MyCMDBUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkInstallStatus: function() {
var recID = this.getParameter("sysparm_ids");
var opStatus = this.getParameter("sysparm_opstat");
// gs.info('checkInstallStatus: sys_id = ' + recID + ', os = ' + opStatus);
var retValue = true;
var item = new GlideRecord('cmdb_ci');
var rec = item.get(recID);
if ((rec) && (item.install_status == 1)) {
// prevent editing for Installed
retValue = false;
}
// gs.info('checkinstallStatus: returning ' + retValue);
return retValue;
},
type: 'MyCMDBUtils'
});
Change names as desired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 09:36 AM
I appreciate your help @Bert_c1 for taking time to build this for me but still its shows same no changes are occurred.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2025 07:02 PM
Hi @SaitejaN ,
To restrict changing the Operational Status in list view when the Install Status is set to "Installed", and to show a popup alert, you can achieve this using a Client Script of type List.
Navigate to: System Definition → Client Scripts
Click New, and configure it as follows:
Name: Restrict Operational Status Change
Table: cmdb_ci (or your specific CI table like cmdb_ci_appl)
UI Type: All
Type: List
Active: True
function onCellEdit(sysIDs, table, oldValues, newValues, callback) {
var installStatusIndex = oldValues.getColumnIndex('install_status');
var operationalStatusIndex = newValues.getColumnIndex('operational_status');
for (var i = 0; i < sysIDs.length; i++) {
var installStatus = oldValues.getValue(i, installStatusIndex);
var newOperationalStatus = newValues.getValue(i, operationalStatusIndex);
if (installStatus == '1' && oldValues.getValue(i, operationalStatusIndex) !== newOperationalStatus) { // 1 = Installed
alert("Cannot change Operational Status when Install Status is 'Installed'.");
callback(false); // cancel the change
return;
}
}
callback(true); // allow change if no violation
}
This script listens for inline edits in list view.
It checks if the Install Status is 'Installed' (value = 1) and prevents any change to Operational Status.
If the condition is met, it shows an alert message and cancels the change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 07:37 AM - edited 06-20-2025 07:38 AM
"List" type is not available in my instance.
the solution proposed before your post works in my instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 09:14 AM
Thanks @Community Alums for the help but its not working its blocking the right green arrow in list view. so when try your code and try to change the operational status its blocking the green arrow to perform an action or noting is happening and no alert message is showing up . Also i tried to change when operational status is retired to different state same issue is happening. Its not allowing to make change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 10:57 AM
Works in my instance:
Seems you need to provide more details on what you're looking for. Such at what table you want to restrict the changing of Operational Status in a list view.