Builder | Using UI policies for dynamic forms
Welcome to part 12 of the Builder series. In this video we’ll demonstrate how you can improve the user experience in the classic form layout by using UI policies to make forms more dynamic. This video is a continuation of the Builder
series and uses the Safety application created earlier. Even if your organization doesn’t have a safety department... ... the concepts demonstrated here apply to a wide variety of use cases. The safety department only cares about the due date for big issues and doesn’t need it for small issues. In fact, the Due date field shouldn’t even
appear on the form if the Category value is Small. So here’s the latest requirement from our
safety department manager, Luke: Display the Due date field on the Issue form
only when the value in the Category field is Big. We’re going to create some quick, no-code logic to make a self-adjusting form to fulfill this requirement. To do that, we’ve logged in to our instance with the admin role, started ServiceNow Studio, and selected our Safety app. We’ll build a UI policy to make the form more dynamic. UI policies are a great way to change the
behavior of information on a form... ... based on the existing form field values, without using
any code. We can make a field hidden or visible, mandatory
or optional, and read-only or editable. We start by clicking Create Application File,
and then selecting Client Development > UI Policy. Here, we select the table that the UI policy applies to. In our case, it’s the Issue table. Next, we provide a short description to make
it easy to identify the purpose of this UI policy. The Order field specifies the order that the
UI policies run... ... when there’s more than one UI policy on the table and they need to run in a certain order. We only have one, so we’ll leave it as-is. Now, in the When to apply section, we build
the conditions that’ll trigger this UI Policy. We want it to run when the Category is Small. In a moment, we’ll specify what actions
to take when our conditions are met. Here’s the plan: When the Category is Small, hide the Due date field. But often, we also want the system to reverse the effects of the action when the conditions are NOT met. For example, if our Category is Small condition
evaluates to false, show the Due date field. And that’s where this Reverse if false checkbox
comes in handy. If it’s selected, when the conditions are
true, actions are taken... ... and when the conditions are false, the actions are automatically reversed, or undone. For example, a field that is hidden by a UI
policy action becomes visible. That’s what we want, so we’ll leave it selected. That takes care of when to apply the UI policy,
so we submit the form… And now we have two new related lists. This is where we define what we want to do
when the condition above is true. We create a new UI policy action…
…and select the Due date field. We set the Visible field to false, indicating that we don’t want the Due date displayed when the category is small. Let’s also select this check box to clear
any existing Due date field value. Even though the Due date field won’t be
displayed on the form... ... it may appear on reports and cause confusion when the Category is Small, so let’s fix it during data entry. Just be aware: If your UI policy clears a
field value, you cannot get the data back. Finally, we submit our UI policy action. And that’s it. Now it’s time to test this on an issue record. When we switch the category from Big to Small, the Due date field disappears and any previous due date is cleared. And when we switch it back to Big, the field
reappears and has no value. Now Luke’s employees are making fewer mistakes,
and he’s getting more accurate reports. And we did that all without any scripting. This is so much better than the spreadsheet
he used before! One final note on UI policies – If your
form needs more than 5 to 10 UI policies... ... loading it can impact system performance and
the user experience. Instead, check into using a feature called a view rule. For more information, see our product documentation,
knowledge base, or podcast. Or ask a question in the ServiceNow Community.
https://www.youtube.com/watch?v=ssK5kaSpIDQ