Business Rule to run with UI Action

rohitservicenow
Mega Guru

I have an UI button(which gets executed on client) on Change form which moves the changes to Asses state based on certain validations. Now I have a requirement to make some additional validations before the change is moved to Asses state. For this I have written a Before business rule firing on state change to Asses, but it's working. It appears the BR is getting fired after UI action making the changes to State. I want to know if it's possible to have the BR execute along with the UI action so that when the UI action sets the change state to Asses and before it's saved to db want to have my Before BR fired and do it's validations. If yes, please advise the procedure. 

 

Thanks in advanced,

Rohit

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

'Before' business rules always run before the record is actually saved to the database.  If you want to move the business rule code into the UI action you can do that using this SNGuru solution.

https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/

View solution in original post

3 REPLIES 3

Mark Stanger
Giga Sage

'Before' business rules always run before the record is actually saved to the database.  If you want to move the business rule code into the UI action you can do that using this SNGuru solution.

https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/

Thank you this has been really helpful

Nitesh Balusu
Giga Guru

Hi Rohit,

 

Instead of writing a business rule and wanting it to run from the UI Action, you could either move the business rule code to the UI Action or instead put all the business rule code in a script include and call the script include from the UI Action (a better solution).

 

Thanks.