Introduction to Formulas
Formulas in Precision Bridge transform, compute, and manipulate data using a Python-like expression syntax. They are evaluated in a secure sandbox environment, providing familiar programming constructs without the overhead of writing full scripts.
Where Formulas Are Used
Formulas appear in several places throughout Precision Bridge:
- Field Mappings (Formula type) -- When mapping fields between source and target systems, you can choose the "Formula" mapping type to compute target values dynamically from source fields, variables, and constants.
- Filter Expressions -- Define conditions to include or exclude records during data extraction and migration.
- Assign Variables Step -- Set procedure-level variables using formula expressions, making computed values available to subsequent steps.
- Other Dynamic Contexts -- Anywhere Precision Bridge needs a computed value, formulas may be available as an option.
Basic Syntax Overview
Formulas are single expressions (not multi-line scripts). They are evaluated once per record during processing and must produce a single return value. There is no need for a return statement -- the result of the expression is the output.
Referencing Source Fields
Use square brackets to reference values from the current source record:
[field_name]
For example:
[short_description]
[priority]
[sys_id]
[assigned_to]
When the formula is evaluated, [short_description] is replaced with the actual value of the short_description field on the current record. If the field does not exist on the record, the value will be None.
Field Names with Spaces or Special Characters
Source field names are taken literally inside the brackets — many enterprise systems (BMC Remedy is a common example) expose fields with raw names like First Name, Internet E-mail, or Submitter Group, and these can be referenced as-is:
[First Name]
[Internet E-mail]
[Submitter Group]
For each source field that contains a non-identifier character (space, hyphen, slash, dot, etc.), Precision Bridge also exposes a safe-name alias — each non-identifier character is replaced with an underscore, with _2, _3 suffixes to disambiguate when two raw names collapse to the same alias:
| Raw field name | Safe-name alias |
|---|---|
First Name |
First_Name |
Internet E-mail |
Internet_E_mail |
Submitter Group |
Submitter_Group |
priority.value |
priority_value |
Either form works inside brackets — [First Name] and [First_Name] resolve to the same field. The autocomplete in the formula editor offers both. Reach for the safe name when you want a name that's unambiguously identifier-shaped, or when copying a formula between contexts where the raw name is awkward to quote.
A third form, source["raw name"], exposes the source record as a dictionary and accepts any raw name verbatim:
source["First Name"]
source["priority.value"]
The source form is the escape hatch for cases where the raw name contains characters that would conflict with bracket parsing (closing brackets, line breaks), or where the field name is being computed dynamically.
Safe names also appear as variables in lookup queries. When a lookup query references a source field, the variable is named
source_<safe_name>— for example, the raw fieldSubmitter Groupproduces the variablesource_Submitter_Group. The safe form is required here because variable names must be identifiers.
Referencing Variables
Procedure variables and mapping variables are referenced directly by name, without square brackets:
my_variable
incident_id_map
counter
Variables are typically set using the Assign Variables step or populated by earlier steps in the procedure.
String Literals
Use single quotes (') or double quotes (") to define string values:
'Hello, world!'
"This is also a string"
Important: Do not use backtick characters for strings. Only single and double quotes are supported.
Arithmetic Operators
Formulas support standard arithmetic operations:
| Operator | Description | Example | Result |
|---|---|---|---|
+ |
Addition | 5 + 3 |
8 |
- |
Subtraction | 10 - 4 |
6 |
* |
Multiplication | 6 * 7 |
42 |
/ |
Division | 15 / 4 |
3.75 |
// |
Floor Division | 15 // 4 |
3 |
% |
Modulo | 17 % 5 |
2 |
** |
Power | 2 ** 10 |
1024 |
String Concatenation
Use the + operator to combine strings:
[first_name] + ' ' + [last_name]
This joins the first_name field, a space, and the last_name field into a single string.
Comparison Operators
| Operator | Description | Example |
|---|---|---|
== |
Equal to | [status] == 'open' |
!= |
Not equal to | [priority] != 5 |
> |
Greater than | [score] > 80 |
< |
Less than | [priority] < 3 |
>= |
Greater than or equal | [age] >= 18 |
<= |
Less than or equal | [count] <= 100 |
Boolean and Null Values
The following constants are available:
-
True-- boolean true -
False-- boolean false -
None-- represents a null or missing value -
Null-- an alias forNone
Worked Examples
1. Append text to a field
[short_description] + ' (migrated)'
Takes the source short_description and appends the text (migrated) to the end.
2. Combine two fields
[first_name] + ' ' + [last_name]
Produces a full name by joining first_name and last_name with a space.
3. Simple arithmetic on a number field
[priority] + 1
Increments the numeric priority value by 1.
4. String with a variable reference
'Migrated from ' + source_instance + ': ' + [sys_id]
Builds a descriptive string using a procedure variable (source_instance) and a source field (sys_id).
5. Null check
'Has value' if [assigned_to] is not None else 'Empty'
Returns 'Has value' if the assigned_to field is populated, or 'Empty' if it is null.
6. Constant value
'Imported'
Returns the string 'Imported' for every record. Use this pattern to set a target field to a fixed value.
Testing a Formula
The formula editor drawer includes a Test button (top-right of the editor) that opens a dialog for evaluating the current formula with sample inputs.
Precision Bridge parses the formula to find:
- Variables it references — each variable is rendered as an input pre-filled with the variable's current value (or default).
-
Source fields it references — each
[field_name]orsource["field_name"]produces a field input typed according to the source table's metadata.
Provide values for any unbound inputs and click Submit to run the formula on the backend. The dialog shows the evaluated result with its data-type label (for example, string, integer, boolean, datetime). If the formula references nothing — for example, concatenate('Hello, ', 'world') — the dialog evaluates immediately on open and skips the input form.
Use the Test button to validate complex transformations before saving them into a field mapping or a filter expression. The evaluation runs entirely server-side against the same expression engine that processes records during execution, so what you see is what you'll get at run time.
Next Steps
- Learn about data types and type conversion in Working with Types
- Explore string manipulation in String Operations
- Discover conditional logic in Conditional Logic
Comments
0 comments
Please sign in to leave a comment.