Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Business Rule Condition (For state change exceptions)

Wasdom_Kung
Tera Guru

Hi,

I currently have a business rule that prevents anyone that is not an itil_admin or admin from updating tickets if they are closed or resolved. 

 

This is the setup:

find_real_file.png

find_real_file.png

One issue I have is that if we go to an existing ticket and attempt to change it to resolved or closed - it won't allow the change. We currently require work_notes to be populated for this action also. 

What would be the simplest way to modify this rule so that it allows updates if the ticket changes to resolved / closed, but ONLY prevent comments and work notes whilst it is already at those states?

1 ACCEPTED SOLUTION

Can you try it like this:

!gs.hasRole('admin') && !gs.hasRole('itil_admin') && !current.state.changes() && (current.state == '7' || current.state == '8')

View solution in original post

7 REPLIES 7

Willem
Giga Sage
Giga Sage

You have to work with an advanced/scripted condition:

!gs.hasRole('admin') && !gs.hasRole('itil_admin') && (!current.state.changes() && (current.state == '7' || current.state == '8')) 

Meaning:

If user does not have admin and does not have itil admin and current state does not change and current state is closed 7 or cancelled 8. Execute your script.

I removed the basic conditions and added to the advanced one. 

When trying to resolve a ticket it says resolved, then the message pops up saying it cannot be edited followed by invalid input.

This is just when saving from New to Resolved and includes work_notes and the resolution details

Can you try it like this:

!gs.hasRole('admin') && !gs.hasRole('itil_admin') && !current.state.changes() && (current.state == '7' || current.state == '8')

Tried that before replying and had the exact same issue sadly, I'll see if changing the BR order number makes a difference at all

Oh just to clarify the roles condition works, it's just as a non-role user this occurs.

Edit: I added in the original conditions with your amendment above and now tickets will save and can be changed without any error messages

So this allows all changes for users

!gs.hasRole('admin') && !gs.hasRole('itil_admin') && !current.state.changes() && (current.state == '7' || current.state == '8')

And this prevents any changes even to 'New' tickets changing status

!gs.hasRole('admin') || !gs.hasRole('itil_admin') && !current.state.changes() && (current.state == '7' || current.state == '8')