logo

NJP

Builder | Filtering a list of records

Import · Jun 01, 2020 · video

Welcome to part 11 of the Builder series. In this video, we’ll demonstrate how to add conditions to filter a list of records to prevent invalid data entry on a reference field. If you haven’t already seen the previous
videos in this series... ... it’s a good idea to watch them to get the most out of this one, which continues with the Safety app we built earlier. Luke Wilson, our Safety department manager, has noticed that our user list includes both current and past employees. If someone selects a past employee for any
of the user fields on our form... ... our Safety Issues process may come to a screeching halt. Luke wants to prevent this by having us add
a filter on the Opened by, Inspector... ... and Assigned to fields to display only current employees. Here, we’re logged in to our instance as
system administrator. You can also do this with the delegated_developer role along with the Tables & Forms access in the developer permissions for this application. Our list of users is kept in sync with our
HR system through regular data imports. So we’re going to trust that the information is correct... ... and our user data accurately reflects each user’s employment status. However, keep in mind that unless such data
is updated in real time... ... there will be a delay in a user’s changed employment status being reflected in the instance. If your ServiceNow instance gets information from other sources... ... make sure you understand how that information is maintained... ... or you could find yourself with obsolete data and your app not working as expected. Here, we’ve started ServiceNow Studio and
selected our Safety app. We begin by navigating to Data Model> Tables
and opening the Issue table. First, we’ll modify the behavior of the
Assigned to field... ... so we click it to open its dictionary entry. A little lower on the form is the “Reference
Specification” section... ... where we can see that this field references the User table... ... and currently there is no Reference qualifier condition defined. The reference qualifier is a filter that restricts
the data that’s returned for a reference field. Without a reference qualifier, all values for the field that is being referenced appear in the reference lookup. That’s why, in our example, a new issue
could be assigned to a past employee. We’re going to change that by setting this
to Active is true and updating it. When employee records are imported from our
HR system... ... the Active field is set to false for any employee who left the company since the previous import. So setting the filter up this way ensures that we’re only able to assign issues to current employees. We’ll make the same quick updates to the
Inspector and Opened by fields... ... so that they also filter out past employees. We’re changing each field individually because
each one may have a different filter requirement. Now it’s time to check our work. Here’s a new issue, and when we try to set the Opened by user to Amelia Caputo, there’s no returned result. Clicking the reference lookup icon displays
a list of records on the referenced table... ... but this also prevents us from selecting past
employees. Problem solved! 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=LujwlWR9aIc