Skip to content
Pages · Configure an entity

Formulas and LOOKUP

Applies to CustomerVendorInvoiceBill

Write a formula#

  1. In the mapping window, open the Salesforce Field list of a row and click Advanced Editor. The Formula editor opens.
  2. Build the formula in Formula Expression. Type it, or use Insert Field, Insert Operator and Insert Function to add pieces at the cursor.
  3. Optional, recommended: in Test with a sample record (optional), search a real record by name.
  4. 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).
  5. Click Insert Formula. It is available only after a successful verify; any change needs a new one.
  6. 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 wantFormula
A default when a field is emptyIF(ISBLANK(Account.Name), "Unknown customer", Account.Name)
A document number with a prefix"SF-" & Name
A name from two fieldsCONCAT(LastName, ", ", FirstName)
A due date 30 days after closeCloseDate + 30
A term that depends on the amountIF(Amount > 10000, "Net 60", "Net 30")
An email in lower caseLOWER(Email)
A value that depends on a multi-select picklistIF(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:

  1. 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.
  2. Set the Return field (the value the formula gives back). For reference data and synced records it starts as the QuickBooks ID.
  3. 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.
  4. 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 wantFormula
The QuickBooks ID of the vendor linked to a billLOOKUP(QB_Vendor__c, QBO_Id__c, SF_Master_Record_Id__c, Vendor__c)
A product's QuickBooks ID by nameLOOKUP(QBO_Reference_Data__c, QBO_Id__c, Type__c, "ItemRef", Name, Product2.Name)
A billing contact's emailLOOKUP(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 functionExample 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.

CodeMeaning
E_SYNTAX_… (for example E_SYNTAX_UNBALANCED_PAREN), E_EMPTYVerify: the formula text is wrong or empty.
E_UNKNOWN_FIELDVerify: a field name does not exist on the object.
E_UNKNOWN_FUNCTION, E_ARITY, E_LOOKUP_ARITYVerify: an unknown function, or the wrong number of arguments.
E_TYPE_MISMATCH, TYPE_MISMATCHValues of types that do not combine, such as text compared with a number.
FORMULA_BLANKVerify with a sample record: the formula produced no value for it.
DIV_BY_ZERODivision by zero.
E_LOOKUP_UNKNOWN_OBJECT, E_LOOKUP_UNKNOWN_FIELD, LOOKUP_BAD_VALUEA LOOKUP names an object or field that does not exist, or a value of the wrong type.
LOOKUP_QUERY_LIMITToo many LOOKUPs ran in one transaction.
PARSESend: 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#