Formulas and LOOKUP
Write a formula#
- In the mapping window, open the Salesforce Field list of a row and click Advanced Editor. The Formula editor opens.
- Build the formula in Formula Expression. Type it, or use Insert Field, Insert Operator and Insert Function to add pieces at the cursor.
- Optional, recommended: in Test with a sample record (optional), search a real record by name.
- Click Verify Formula. You see "Formula is valid and ready to use." With a sample record you also see the value it would send (a formula without fields shows its result even without one).
- Click Insert Formula. It is available only after a successful verify; any change needs a new one.
- Save the mapping as usual.

The Formula editor: 2 build the formula, with the Insert buttons above it; 3 a sample record; 4 Verify Formula, with the result for the sample record; 5 Insert Formula. The numbers match the steps above.
Recipes#
| You want | Formula |
|---|---|
| A default when a field is empty | IF(ISBLANK(Account.Name), "Unknown customer", Account.Name) |
| A document number with a prefix | "SF-" & Name |
| A name from two fields | CONCAT(LastName, ", ", FirstName) |
| A due date 30 days after close | CloseDate + 30 |
| A term that depends on the amount | IF(Amount > 10000, "Net 60", "Net 30") |
| An email in lower case | LOWER(Email) |
| A value that depends on a multi-select picklist | IF(INCLUDES(Services__c, "Installation"), "Install", "Supply") |
Look a value up with LOOKUP#
LOOKUP finds one record in any object and returns one of its fields: "in object X, find the record whose field A equals this value, and give me its field B". In the editor, Insert Reference Value opens Insert a LOOKUP, which writes it for you:
- Step 1: What do you want to look up? Choose Reference data (QBO cached lookups), Shadow objects (synced QBO records) or Any other object, then Continue.
- Set the Return field (the value the formula gives back). For reference data and synced records it starts as the QuickBooks ID.
- Under Conditions (all must match), pick each Field and what its value is (Value is): a Literal value, Pick a record, or a Field of the source record. Use Add condition for more.
- Check the Preview and click Insert. Then verify the formula as usual.

Insert a LOOKUP, step 1: the reference data types, the synced QuickBooks records (shadow objects), or any other object.
LOOKUP examples
| You want | Formula |
|---|---|
| The QuickBooks ID of the vendor linked to a bill | LOOKUP(QB_Vendor__c, QBO_Id__c, SF_Master_Record_Id__c, Vendor__c) |
| A product's QuickBooks ID by name | LOOKUP(QBO_Reference_Data__c, QBO_Id__c, Type__c, "ItemRef", Name, Product2.Name) |
| A billing contact's email | LOOKUP(Contact, Email, AccountId, Id, Title, "Billing Contact") |
No match returns an empty value, and only the first match is used. Wrap a LOOKUP in IF(ISBLANK(LOOKUP(...)), fallback, LOOKUP(...)) when it may find nothing.
Operators and functions#
| Operator or function | Example or what it does |
|---|---|
== != | StageName == "Closed Won" |
> < >= <= | Amount > 1000 |
&& || ! (or AND, OR, NOT) | Amount > 0 && !ISBLANK(Name) |
+ - * / | Quantity * UnitPrice |
& (join text) | "INV-" & Name |
| IF(test, then, else) | One of two values |
| ISBLANK(value) | True when empty |
| NOT(value) | Inverts true and false |
| CONCAT(text1, text2, ...) | Joins text |
| TEXT(value) | A number, date or checkbox as text |
| LOWER(text), UPPER(text) | Text in lower or upper case |
| STARTSWITH(text, prefix), ENDSWITH(text, suffix), CONTAINS(text, part) | True when the text starts with, ends with or contains it |
| INCLUDES(multiselect, value) | True when a multi-select picklist includes the value |
| SAMEVALUES(multiselect, other) | True when two multi-select values hold the same items, in any order |
| TODAY() | Today's date |
| DATEVALUE(value), DATETIMEVALUE(value) | A date (or date and time) from a date/time or text such as "2026-11-30" |
| LOOKUP(Object, ReturnField, MatchField, value, ...) | One value from another record |
The Insert Function menu lists the most used ones; you can type all of them.
Rules worth knowing
- Write fields by API name, as Insert Field inserts them:
Name,Account.Name,Vendor__r.QuickBooks_Id__c. - Text goes in quotes:
"Net 30"or'Net 30'. - A date plus a number adds days; a date minus a date gives the number of days between them. Dividing by zero is an error.
- A Date/Time sent to a QuickBooks date becomes a day in the org's default time zone, whoever saved the record.
Error codes#
Verify Formula reports codes starting with E_, with the position in the formula. A send reports the shorter codes.
| Code | Meaning |
|---|---|
E_SYNTAX_… (for example E_SYNTAX_UNBALANCED_PAREN), E_EMPTY | Verify: the formula text is wrong or empty. |
E_UNKNOWN_FIELD | Verify: a field name does not exist on the object. |
E_UNKNOWN_FUNCTION, E_ARITY, E_LOOKUP_ARITY | Verify: an unknown function, or the wrong number of arguments. |
E_TYPE_MISMATCH, TYPE_MISMATCH | Values of types that do not combine, such as text compared with a number. |
FORMULA_BLANK | Verify with a sample record: the formula produced no value for it. |
DIV_BY_ZERO | Division by zero. |
E_LOOKUP_UNKNOWN_OBJECT, E_LOOKUP_UNKNOWN_FIELD, LOOKUP_BAD_VALUE | A LOOKUP names an object or field that does not exist, or a value of the wrong type. |
LOOKUP_QUERY_LIMIT | Too many LOOKUPs ran in one transaction. |
PARSE | Send: the stored formula could not be read. Open it in the editor and verify it again. |
The full list is in Messages and error codes.
Where to next#
- Outbound: the Sync to QuickBooks action: send a record
- Mapping: references and line items: how names become IDs