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.

Need to make Additional Comments mandatory when State in On hold or if On hold reason changes

Mallika Bhupath
Tera Contributor

All,

 

I need to make the Additional Comments field mandatory on the Incident form when 
1) When the state is changed to On hold or

2) When the On hold reason changes

 

I have created a UI Policy as shown here.

MallikaBhupath_0-1687805851476.png

However, whenever I submit additional comments and Save it, the * does not leave the field when the State is On hold and reason is anything.

 

Any help is appreciated.

 

Thanks,

Mallika

1 ACCEPTED SOLUTION

Patrick Laroch1
Tera Guru

No need for the Client script, just make sure the the "On load" field is FALSE.

View solution in original post

4 REPLIES 4

jMarshal
Mega Sage

...because you're doing it as UI Policy, it doesn't "trigger" -- it is state-based, and *whenever* the state is on hold, it will apply. This is why it is "not going away" when it is "satisfied" (it can't continually be satisfied because it's a journal field type - constantly open to input, never "full").

If you want to enforce a comment when it is put on hold, but not while it stays on hold, you may want to use a Client Script instead, so that it can trigger onChange...then the script should (if the "additional comments" is empty), display a message and then reset the status (to not On Hold).

End user would select "on hold" and then select a reason, without any comments, if they "save/submit/insert/update", the client script will say "nope - gotta have a comment" and set the state to previous (in progress or whichever).

Hi @jMarshal 
 This is the client script that I have created.

MallikaBhupath_0-1687808459539.png

It does not seem to be working.

Patrick Laroch1
Tera Guru

Make sure the UI Policy looks like this

PatrickLaroch1_0-1687806927476.png

 

Patrick Laroch1
Tera Guru

No need for the Client script, just make sure the the "On load" field is FALSE.