prevent change request closing without approvals

mick1
Kilo Contributor

I am new to being an admin for ServiceNow. We have been having an issue where our users are closing their change request even though it has not gone through the whole approval process. I am trying to find a way to prevent this from happening with the tool.

Is there a way from preventing the users from updating their change "State" from "Pending or Open" to "Close Complete or Close Incomplete" if the "Approval" attribute is anything besides approved?

13 REPLIES 13

Hi Mickey,



  1. Remove "current.setAbortaction(true);" from your Condition.
  2. Set your script to:

          function onBefore(current, previous){
                  current.setAbortaction(true);
          }


With that line commented, it won't do anything.



Also, try using "State changes to Completed" and "State changes to Failed" instead of equals (is) for your conditions.





-Brian


Hi Brian,


I have removed the condition and changed the change to but it is still allowing me to close my tickets without being approved. Do you see any mistakes or have any other suggestions?








Best regards,


Mickey Do


Hi Mickey,



Two things to correct:


  1. This first one is my fault, the script is case-sensitive and I made a typo in the method name.   It should be (make sure both "A"s are capitalized):

            current.setAbortAction(true);

  2. And in your condition, make it:

            Approvals is not Approved
            AND ("State changes to Completed" OR "State changes to Failed")


Right now, you have it using only AND, which means all the conditions must be true at once.




-Brian


Brian,


I took out the other state just to make sure it worked and it's still a no go.








Best regards,


Mickey Do


Hi Mickey,



You need to check the options for "Update" and "Insert", otherwise it doesn't have a "when" to apply the business rule.




Thanks,


-Brian