Set Error Message within Business Rules

kiley
Giga Contributor

So for my current project, I need to set an error message on a planned start date field or planned end date field if they are outside the parameters set. I have everything working fine, meaning my conditions are all correct, but I cannot figure out how to get the error message to appear. Here is the code:

current.u_planned_end_date.setError("Please change the above date");

current.u_planned_start_date.setError("Please change the above date");



the names are correct (u_planned_etc.), for they worked in other code used inside the same rule, and I tried using "gs" instead of "current" just in case that was an option and it still did not work. Any ideas?

Thank you in advance!

Update: I found that code through the wiki page Scripting Alert, Info, and Error Messages - ServiceNow Wiki

1 ACCEPTED SOLUTION

5 REPLIES 5

Mike Allen
Mega Sage

I was able to get this to work out of the box.   I had a before insert/update business rule that set the error and aborted the action.



Are you using business rules or client scripts?


Capture2.PNG


Capture3.PNG



Capture.PNG


kiley
Giga Contributor

thank you but that is the link i actually included in my initial description