- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 09:33 AM
I am trying to put in place a Business Rule or Client Script or UI Action that prevents all users, except Discovery Admins, from creating a new CI when submitting new CHG or INC tickets.
I have tried an ACL that prevents creation of cmdb_ci items, but it did not work.
I tried a Client Script like below, but it did not work:
function onLoad() {
var ciField = g_form.getControl('cmdb_ci');
if (ciField) {
// Using ServiceNow API to hide the "New" button
g_form.setReadOnly('cmdb_ci', true); // Makes the field read-only
g_form.setReadOnly('cmdb_ci', false); // Unlocks it while keeping "New" button hidden
}
}
All things that have been suggested through AI have not worked thus far. (ChatGPT)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 11:01 AM
The easiest way to do this it to right-click on the column headers in the Configuration Item list in the reference search window and choose Configure > List Control. If you do not have a script field on this form for Omit new condition, add it via Form Layout. In this field you can use a script like this:
if (gs.hasRole('discovery_admin')) {
answer = false;
} else {
answer = true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 11:20 AM
You are welcome! Happy to help!