logo

NJP

Builder | Validating data with business rules

Import · Jun 01, 2020 · video

Welcome to part 10 of the Builder series. In this video, we’ll demonstrate how you can strengthen your processes by using business rules to validate your data. It’s a good idea to watch the previous Builder
videos to get the most from this one... ... which builds on the Safety Department use case,
using the Safety app we created earlier. While your organization may not have a safety department... ... the concepts presented here apply to a wide variety of scenarios common to most businesses. Let’s take a look at our latest requirement
from Luke, our Safety Department manager. Luke noted that some users are entering invalid
due dates when they create new safety issues. Some people are trying to game the system
by using dates in the past. Luke wants us to implement a way to prevent this. And we’ve got a no-code solution. Here, we’ve logged in to our instance with
administrator credentials... ... started ServiceNow Studio, and selected the Safety application. You can also do this with the delegated_developer
role, with granted access to All File Types. For this requirement, we’re going to use
a Now Platform capability called a Business Rule. We begin by clicking Create Application File in Studio... ... and under Server Development, we select Business Rule and click Create. Business Rules run automatically when a record
is created, read, updated, or deleted. Our business rule will check the due date
when a new safety issue is created or updated. Let’s give the business rule a name to help
identify its purpose. The Table field specifies which table the
business rule should monitor for record changes. In our case, it’s the safety issue table. Lower on the form, we have two sections to complete. When to run identifies the conditions to trigger
this business rule... ... and Actions specifies the actions to take when it’s triggered. We’ll start by selecting these check boxes
because we want to validate the due date... ... not only when safety issues are inserted (or created),
but also when they’re updated. And we need to add conditions to run this
particular rule only when the Due date changes... ... AND... ... the Due date is at or before today. Pretty simple. Now we specify what to do when the business
rule is triggered. For that, we’ll switch to the Actions tab. In some business rule cases, we may want to
set some field values. But in this case, we’ll display a message
warning the user about a potential data entry issue. And we’ll select this check box to abort
the current database transaction... ... preventing the record from being inserted or updated. Finally, we save our work by clicking Submit. Now to test our new business rule… Here, if we enter a date in the past and try
to submit the issue... …The business rule checks the Due date value
and displays the message. And if we enter a future date and submit it… …Our record is saved. Business rules have a lot of other uses in
applications and process flows. They provide a quick way to check for conditions
and run simple actions. For more information, see our product documentation,
knowledge base, or podcast. Or ask a question in the ServiceNow Community.

View original source

https://www.youtube.com/watch?v=lC-lh1R5zM8