- 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 12:02 PM
I wonder cause I did Exactly the code you provided even I created new record on same name. I don't know why its not working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 12:17 PM
Did you added Field Name In client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 01:15 PM
Hey @Bert_c1 Its Working thank u so much😀.