Rule Formulas
  • 15 Apr 2025
  • 4 minute read
  • Dark
    Light
  • PDF

Rule Formulas

  • Dark
    Light
  • PDF

Article summary

Rule Formulas allow you to use a combination of exports to set a value. Formulas are supported with the following Rule Types:

  • Field

  • Application Header

  • Person Header

  • Person Index

  • Dataset Index/Header

  • Dataset Username

  • Dataset Name

This article will first explain how Formulas work, as the usage is exactly the same regardless of the Rule Type, and then it will provide some examples.

A note about field rules

Rule formulas do not work with all fields. In general, prompt-driven fields cannot be set using a rule formula. The exception are fields that use country, language, state, or user as their prompt setting. These special prompts are discussed later in the article.

How Formulas Work

When the Action of a Rule is set to Replace Values from Formula, you are presented with the ability to add Exports and Joins.

You can add base joins (one-to-one joins) and any direct exports or subquery exports as needed. Exports must have a name with no spaces or special characters.

To use the exports in the formula, add an @ symbol in front of the export name. For example: @ref_id.

You can use the Join button to access the exports on another table. Since the base of the rule acts like the base of a query, these joins are one-to-one.

Why are the joins one-to-one?

Even though rules act on many records throughout your instance, each rule evaluates individually for each record. The values in the formula have to be single values so Slate can calculate the formula and store the single value onto the record being processed by the rule.

Simple Formula Rules

In many cases, you only need one export in your formula: a single subquery export that handles all of the logic.

There many benefits to this approach:

  • You might not need to write a formula at all. For example, by using the Coalesce or Concatenate output setting.

  • You can configure your subquery export just like you would in a query, giving you familiarity and minimizing possible mistakes.

  • It can simplify the logic since only one item is needed.

A good example is a Person Header rule. This type of rule allows you to modify the text that appears under a person’s name when using the omni search.

Although the value shown in the screenshot is the default, we could replicate it using a single subquery export:

Complex Formula Rules

Rule formulas can use the exact same formula elements as formulas in queries. We recommend reviewing the linked article to understand the most common ways formulas can be used.

Example: Performing Calculations

Rules can perform mathematical operations like addition (+), subtraction (-), multiplication (*), division (*), and modulo (%). When writing mathematical formulas, double-checking the data type of each element becomes important.

Of course, mathematical operations can be performed with a simple formula by using a subquery export. For example, if we have a Scholarships entity, we can Sum all of the values in the Amount field:

However, we may have data in more than one place. In this example, we also have a flat field that stores the value of the Presidential Scholarship, which is not included in the Scholarships entity. After adding it as an export, we have the following formula:

Make sure to choose the correct Format Type for each export. A numeric format (Real, Integer, or Money) must be chosen in order for the calculation to work.

Special Prompt Values

Most prompt-driven fields can’t be set with a rule formula, since they store the GUID of the selected prompt. However, there are a few prompts which get stored as text, allowing them to be set via formula:

  • country fields store the two-letter country code (e.g. “US”). Although these are not GUIDs, the codes can be found using the “GUID” export on the System > World - Country base.

  • language fields store the two-letter language code (e.g. “EN”). These codes are the Index values on the “language” prompt, which can be queried using the System > Prompt base.

  • state fields store the two-letter state code (e.g. “OR”). These codes can be found using the “Alpha2” export on the System > World - Region base.

  • user fields store usernames. These can be found using the “Username” export on the Related > User base.

Example: Staff Assignment by Formula

In this example, we’ll be using a translation code that takes in a state/region and exports the username of a staff member. We’ve set this up using the translation code source format to easily populate our values:

Next, we’ve set up a Field rule, chosen the Staff Assigned field, and selected the Replace Values from Formula option:

To figure out the student’s state, we’ll make a base join to Address by Rank Overall and choose the rank 1 address. Next, we’ll add the export for Region:

We now need to edit this export to give it a machine-friendly name (no spaces) and apply the translation code:

Our rule is now almost complete. We just need to add the export to the formula using the @ symbol:

That’s it! Our rule uses the student’s address, looks up the relevant staff member using the translation code, and sets the Staff Assigned field - all with a very simple formula and no subqueries needed.


Was this article helpful?