#### This topic will walk you through how to handle formula errors.

Workflow Designer formulas enable you to build complex logic calculations directly into your workflow configurations. This reduces manual data entry in launch forms and gives legal teams confidence that the data in their contracts is calculated correctly.

Formulas are a powerful way to automate complex calculations that live within your templates, however, they can increase the complexity of your workflow building process. Formulas are built with a few guidelines to ensure you do not have any unexpected outcomes in your workflows.

## Handle a Calculation Error While Launching a Workflow

Formulas can produce an error when a workflow is launched. In most cases, this is because the formula references a value that was not collected in the form, likely because the related form question was not conditionally triggered. The errors don’t correct the conditional form questions; rather, the errors help identify what information wasn’t collected and from what form question.

If the formula in question is only intended to compute in certain instances, you can wrap the formula in conditional logic, such as an IfExists() function.

## Handle a Formula Error While Building a Workflow Configuration

When you create formulas, Workflow Designer validates the formulas and provides helpful error messages inline, as you’re creating your formulas. Additionally, if your workflow configuration changes such that a formula becomes invalid (for example, if you change a property type from number to string), Workflow Designer alerts you of the incorrect formula.

## Use IfExists () to Handle a Formula Error

Formulas enable you to take in an input value from a user, and use that to calculate another value in your workflow configuration. If an input property connected to a formula does not have a value, you may see an error when you try to launch a workflow. This error can happen for two reasons:

- The input property is optional, so the individual starting the workflow did not enter the value.
- The input property is set to be conditionally triggered. The conditions were not met, so the value was not entered.

To handle this error, you can utilize a formula called IfExists(). IfExists() allows you to define what a formula should do when a certain property has a value (happy path). This formula returns an empty value when a certain property has no value (unhappy path).

In the previous example, you can use it like so to prevent error states from occurring:

###

Use Case

For example, WonderWeb Inc. creates a formula for their workflow’s subscription expiration date. They add theSubscription Start Date and the Subscription Term Length to calculate the Subscription Expiry Date.

RelativeDate([SubscriptionStartDate], [SubscriptionTermLength], “months”)

When they try to launch their workflow, they receive an error. This is because [SubscriptionTermLength] is a property tagged to a conditional question, and the value is not captured since the condition is not triggered. To handle this error state, they use IfExists().

They update their formula to the following:

IfExists([SubscriptionTermLength], relativeDate([SubscriptionStartDate], [SubscriptionTermLength], “months”)

The **Subscription Expiry Date** is calculated as:

relativeDate([SubscriptionStartDate], [SubscriptionTermLength], “months”)

when **[SubscriptionTermLength]** has a value.

And returns:

Empty

when** [SubscriptionTermLength]** has no value