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

You are welcome! Happy to help!