Need help writing an OnCell Edit Script on Hardware Table
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 02:14 AM
Hi,
I need to write an OnCellEdit script on " Hardware Status " field on hardware table.
Old Requirement: Users which doesn't have ecmdb_admin role can't change the Hardware status to "Stolen/Lost".
For that I wrote the below OnCellEdit client script on Hardware table for field Hardware status.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
if (newValue == 'stolen' && g_user.hasRole('ecmdb_admin')){
callback(true);
}
else if (newValue != 'stolen'){
callback(true);
}
else {
callback(false);
alert("Not allowed to update the Hardware Status to Stolen/Lost");
}
callback(saveAndClose);
To this I have to add a condition
If the environment is Development or Test , then Users which doesn't have ecmdb_admin role can't change the Hardware status to "Stolen/Lost". so please help me with the new condition, how can I add the new condition in the working script.
Thanks,
Ankita
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 05:19 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader