Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Validate Data and Handle Errors

Learning Objectives

After completing this unit, you’ll be able to:

  • Explain why it’s important to prevent user errors.
  • Prevent errors with a Set Values element.
  • Ensure data is complete with a Set Errors element.

Two Elements to Prevent User Errors

You’ve been focusing on making an interaction that guides and assists end users who need to edit primary contact information for accounts in your database. You’ve kept the user’s perspective in mind as you build your OmniScript. However, it’s also vital to build an interaction that helps preserve your database’s integrity. 

To do this, consider what kind of errors a user might make when completing your OmniScript. Then think about what type of error checking you want to configure to help prevent these mistakes. Preventing end user errors helps them, but, more critically, it protects the integrity of your data!

You already configured some simple data validation when you set fields as required. After all, the OmniScript won’t let a user move forward if a field is empty. Set Values elements prevent users from moving forward if they haven’t taken an action, and Set Errors elements make users return to a previous step if they make a mistake. 

Let’s take a closer look at these two helpful elements.

How Set Values Elements Prevent Errors

Set Values elements have a lot of potential in an OmniScript. You can use them to do the following things. 

  • Access and rename data JSON by using merge fields.
  • Populate elements with values.
  • Concatenate values (bring two values together into a single, combined value).
  • Define values sent into the data JSON from a response or parameter.
  • Create values determined by OmniScript Functions and Supported Formula Operators.

Let’s look at how to use a Set Values element with a formula to prevent end user error. 

In your OmniScript, you decide to use a Set Values element with an IF formula that displays “Not OK” in the JSON if key fields from each of the three branches are null (empty), and “OK” if there’s data in at least one of the branches.

IF formula with a breakdown of the logic and examples of what the JSON looks like

If the user generates a null (does not complete any change to the primary contact data), you have identified the error in the JSON. Great. But how do you redirect the end user to fix the error? That’s where Set Errors elements come in. 

Set Errors Elements Ensure Data Is Complete

A Set Errors element can send the end user back to an incomplete step and help them fix that problem. This ensures the data is complete. Required fields and formula messaging in the UI only work on the current step. Set Errors elements, on the other hand, work for future steps. It’s worth mentioning again that this helps ensure that the data is complete. 

Let’s consider a different example. You’ve designed a four-step interaction that helps users sign up for cell-phone service. In Step one, the user enters key contact data. In Step four, the user selects a checkbox to receive a text message when they reach 80% of their data usage. But what happens if they select that checkbox but didn’t provide a mobile phone number in Step one? A Set Errors element returns the user to Step one so they can fill in the mobile phone number field. 

Let's go back to your primary contact OmniScript. It only has one Step element. So what do you do if key fields from each branch are null? And what if there is no primary contact in the first place? You can highlight the error for the user and ask that they fix it using a Set Errors element. Let’s see how.

First, for a Set Errors element to work, you need three properties.

Property

Description

Element Error Map

Tells the system which element displays the error message.

Value field

Defines the instructional text you display.

Conditional View

Defines when the element fires.

In your OmniScript, you configure the following Set Errors properties. 

  • Element Error Map: Radio Buttons element.
  • Value field: You remind end users they need to change or create a new primary contact.
  • Conditional View: You set the Conditional View to display the instructional text if there is no primary contact.

Once you have set these up, you’re good to go (or you’re good to send them back).

Error message displayed below the radio buttons when data is missing

Doesn’t it feel good to prevent user errors? In the next unit, you learn how to display external data in your OmniScript.

Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기