Trying to Create Rule to Prevent Regular Users From Creating New Configuration Items

chrisinhoff
Tera Contributor

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)

1 ACCEPTED SOLUTION

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: 

BradBowman_0-1729101588655.png

 

 if (gs.hasRole('discovery_admin')) {
	answer = false;
 } else {
	answer = true;
 }

 

View solution in original post

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

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?

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.

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: 

BradBowman_0-1729101588655.png

 

 if (gs.hasRole('discovery_admin')) {
	answer = false;
 } else {
	answer = true;
 }

 

That worked great, thank you so much for your fast response!