Openflow Connector for Salesforce Bulk API: Salesforce formula fields

This topic describes how the Openflow Connector for Salesforce Bulk API translates Salesforce formula fields into Snowflake SQL views, including supported functions and limitations.

How formula views work

When Enable Views Creation is set to true, the connector performs the following for each object that has formula fields:

  1. Retrieves the formula expressions from the Salesforce object metadata via the Describe API.
  2. Parses each formula expression and translates it into equivalent Snowflake SQL.
  3. Generates a CREATE OR REPLACE VIEW statement that combines non-formula columns from the base table with the translated formula expressions as computed columns.
  4. Runs the DDL against Snowflake to create or update the view.

The resulting view is named <Object Type>_FORMULA_VW. For example, the Account object produces a view named ACCOUNT_FORMULA_VW. You can query this view to obtain formula field values alongside the replicated data.

The view is automatically updated whenever the connector detects schema changes in the source object, ensuring that formula definitions stay in sync with Salesforce.

Cross-object formula fields

Salesforce formulas can reference fields from related objects using relationship traversal (for example, Account.Owner.Name). The connector supports these cross-object references by generating LEFT JOIN clauses in the view definition. Each relationship traversal produces a join to the corresponding related table in Snowflake.

Relationship paths can span several objects, for example Case_No__r.Contact.LastName or CreatedBy.Profile.Name. Each hop is resolved against the object reached by the previous hop, and each hop produces its own join. Polymorphic relationships written with a type, such as Owner:User.Email, join to the object of that type. The type must be one of the objects that the relationship can reference. The Queue type resolves to the Group object, where Salesforce stores queues.

For cross-object formulas to work correctly, every object along the relationship path must also be replicated by the connector. If an object on the path is not being synced, the formula columns that reference it are replaced with a typed NULL in the view, with a TARGET_OBJECT_NOT_REPLICATED comment. If the referenced field of a replicated related object is not synced, the column comment is TARGET_COLUMN_NOT_REPLICATED. The remaining formula columns continue to compute normally. Once the referenced objects and fields are added to replication and synced, the view is automatically rebuilt on the next connector run.

Chained formula fields

Formula fields that reference other formula fields (chained formulas) are supported. The connector resolves the dependency graph before SQL generation and expands each referenced formula field’s expression into the referencing formula’s AST. Multi-hop chains are fully expanded. If a dependency cannot be translated, the dependent field also returns NULL and the column comment indicates FORMULA_CHAIN_NOT_SUPPORTED.

Formula view column comments

Each formula column in the generated view includes a SQL COMMENT annotation:

  • For successfully translated formulas, the comment contains the original Salesforce formula expression.
  • For formulas that could not be translated, the comment contains the failure reason code followed by the original Salesforce formula expression, separated by a colon (for example, FUNCTION_NOT_SUPPORTED: IMAGE(url, 'alt')).

You can inspect these comments by running DESCRIBE VIEW <view_name> in Snowflake.

Supported formula functions

The following Salesforce formula functions are translated into equivalent Snowflake SQL:

CategorySalesforce functionSnowflake equivalent
LogicalIFCASE WHEN ... THEN ... ELSE ... END
LogicalCASECASE ... WHEN ... THEN ... ELSE ... END
LogicalAND / OR / NOTAND / OR / NOT
Null handlingISBLANK(expr IS NULL OR TO_VARCHAR(expr) = ''); returns FALSE for boolean fields
Null handlingISNULLexpr IS NULL
Null handlingNULLVALUECOALESCE
Null handlingBLANKVALUECASE WHEN expr IS NULL OR TO_VARCHAR(expr) = '' THEN default ELSE expr END
TextLEFTLEFT
TextRIGHTRIGHT
TextMIDSUBSTR
TextLENLENGTH
TextSUBSTITUTEREPLACE
TextTRIMTRIM
TextUPPERUPPER
TextLOWERLOWER
TextCONTAINSCONTAINS
TextBEGINSSTARTSWITH
TextFINDCHARINDEX
TextLPADLPAD
TextRPADRPAD
TextBRNewline character literal
ConversionTEXTCAST(... AS STRING)
ConversionVALUETRY_CAST(... AS NUMBER)
MathABSABS
MathROUNDROUND
MathCEILINGCEIL
MathFLOORFLOOR
MathMODMOD
MathSQRTSQRT
MathMAXGREATEST
MathMINLEAST
MathLOGLOG(10, ...)
MathEXPEXP
MathLNLN
Date and timeNOWCURRENT_TIMESTAMP()
Date and timeTODAYCURRENT_DATE()
Date and timeYEARYEAR
Date and timeMONTHMONTH
Date and timeDAYDAY
Date and timeDATEVALUETO_DATE
Date and timeDATETIMEVALUETO_TIMESTAMP
Date and timeADDMONTHSDATEADD(MONTH, ...)
PicklistISPICKVALCOALESCE(field, '') = COALESCE(value, '')

In addition to functions, the following operators are supported:

  • Arithmetic: +, -, *, /, ^ (exponentiation, translated to POWER)
  • Comparison: =, ==, !=, <>, <, <=, >, >=
  • Logical: AND, OR, &&, ||
  • String concatenation: & (translated to || with COALESCE null handling)
  • Unary: - (negation), NOT

Unsupported formula constructs

The following formula constructs are not yet supported. Support for additional functions and constructs will be added in future releases. When a formula uses any of these, the corresponding column in the view returns NULL and the column comment indicates the failure reason.

Failure reasonDescription
FUNCTION_NOT_SUPPORTEDThe formula uses a function that has no Snowflake equivalent or that is specific to the Salesforce UI. This includes: IMAGE, HYPERLINK, URLFOR, HTMLENCODE, JSENCODE, LINKTO, GEOLOCATION, DISTANCE, VLOOKUP, REGEX, PREDICT, GETSESSIONID, GETRECORDIDS, REQUIRESCRIPT, ISCHANGED, ISNEW, ISCLONE, PRIORVALUE.
GLOBAL_VARIABLE_NOT_SUPPORTEDThe formula references a Salesforce global variable such as $User.Name, $Organization.Name, or $Profile.Name. These variables have no equivalent in Snowflake.
FORMULA_CHAIN_NOT_SUPPORTEDA formula field in the chain could not be translated. When a formula field references another formula field (a chained formula), the connector expands the dependency before translation. If the dependency itself fails to translate, the referencing formula also fails with this reason code. This can also occur for cyclic formula references, which are not allowed by Salesforce.
ROLLUP_NOT_SUPPORTEDThe field is a rollup summary field rather than a formula field. Rollup summaries aggregate data from child records and cannot be expressed as a simple SQL view.
LOOKUP_NOT_SYNCEDThe formula references a relationship that cannot be resolved from the Salesforce object metadata. This typically occurs when a relationship name in the path does not exist on the object it is applied to, or when the type of a polymorphic hop (for example Owner:Account) is not one of the objects that the relationship can reference.
TARGET_OBJECT_NOT_REPLICATEDAn object on the relationship path of a cross-object reference is not replicated by the connector. Add the object to replication to resolve the formula.
TARGET_COLUMN_NOT_REPLICATEDThe formula references a field that is not present in the replicated destination table, for example because it is excluded by Object Fields Filter JSON. Add the field to replication to resolve the formula.
TARGET_OBJECT_NOT_REPLICATEDThe formula references a related object that isn’t being replicated to the destination, so the view column returns NULL. To resolve this, add the object to the replication scope.
TARGET_COLUMN_NOT_REPLICATEDThe formula references a column that isn’t present in the destination, for example because a field filter excluded it. This applies to references on the same object and to cross-object references. To resolve this, include the field in the replication scope. Unlike most other reason codes, this one and TARGET_OBJECT_NOT_REPLICATED depend on your replication configuration rather than on the formula itself.
ID_FORMAT_MISMATCHThe formula contains a hardcoded 15-character Salesforce ID. Salesforce uses 15-character IDs internally, but the Bulk API returns 18-character IDs. Formulas with hardcoded 15-character IDs cannot be reliably translated.
COMPOUND_FIELD_REFERENCEThe formula references a compound field (such as MailingAddress) that is not stored as a single column in Snowflake.
PARSE_ERRORThe formula expression could not be parsed. This might indicate a syntax that the connector does not yet recognize.
UNSUPPORTED_SYNTAXThe formula uses a syntax construct that is recognized but cannot be translated (for example, an IF function with fewer than three arguments).