- 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 10:47 AM - edited 10-16-2024 10:52 AM
Are they able to create CIs via the New button on the Configuration item reference search (magnifying glass icon) window, or using some other method? Do you want this to be available to those with the admin role also, or only discovery_admin?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 10:51 AM
Yes, if they do not find the CI they want, there is a "New" button and it works for anyone that can see and use it. It actually redirects to the screen where they fill in the CI line items.
- 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:14 AM
That worked great, thank you so much for your fast response!