🔢 Appendix B: Formula Reference

SQL and SuiteScript Formula Quick Reference

Formula Types

TypeTriggerSyntax
SQL FormulasServer triggers{field_id}
SuiteScript FormulasClient triggers'field_id' in API calls

⚠️ Important

Mismatched formula/trigger types will be ignored and show "ERROR: Invalid expression" in logs.

SQL Formula Functions

FunctionPurposeExample
LENGTH()String lengthLENGTH({phone}) > 10
UPPER() / LOWER()Change caseUPPER({name})
SUBSTR()Extract substringSUBSTR({email}, 1, 5)
INSTR()Find positionINSTR({email}, '@')
NVL()Handle nullsNVL({amount}, 0)
TO_CHAR()Format number/dateTO_CHAR({amount}, '999,999')
TO_NUMBER()Convert to numberTO_NUMBER({text_field})
CASE WHENConditional logicCASE WHEN {status}='A' THEN 'Active' END
||Concatenate{first} || ' ' || {last}

SQL Formula Examples

{custrecord_salary} * 1.05
{phone} || '-' || {zipcode}
SUBSTR({email}, INSTR({email}, '@') + 1)
UPPER({custrecord_code}) NOT IN ('A', 'B', 'C')

SuiteScript 1.0 Functions

FunctionPurpose
nlapiGetFieldValue('fieldId')Get field value
nlapiSetFieldValue('fieldId', value)Set field value
nlapiGetFieldText('fieldId')Get list field display text
nlapiLookupField(type, id, fields)Look up field on another record
nlapiGetUser()Get current user ID
nlapiGetRole()Get current role ID

SuiteScript Formula Example

nlapiGetFieldValue('custrecord_rating_code').length < 10

📋 Note

Only SuiteScript 1.0 is supported in formula conditions. SuiteScript 2.0 requires Workflow Action Scripts.

Field Reference Syntax

ContextSyntaxExample
SQL - Base field{field_id}{phone}
SQL - Related record{record.field}{customer.email}
SQL - Custom field{custrecord_xxx}{custrecord_rating}
SuiteScript'field_id''custrecord_rating'
← Back to Course Overview