Real-Time Integrations in the VanillaSoft Unite app can be configured to Trigger by Custom Expression. For this feature, a trigger is defined with a custom Boolean expression that references one or more Salesforce fields. When an instance of an object (Lead, Contact, or Opportunity) is modified, an update will only be sent to VanillaSoft if the custom expression evaluates to True using the current field values.
Jump to a specific area of this article by selecting one of the sections here:
- Using Trigger by Custom Expression
- Defining Custom Expressions
- Using Fields
- Using Operators
- Using Functions
- Validation
Using Trigger by Custom Expression
When defining a trigger you must check the Use Custom Expression checkbox to enable the option.
After you check the box you will be able to enter a custom expression.
Defining Custom Expressions
Custom expressions can be defined using the names of object fields, literal values, functions, and operators. Both standard fields and custom fields can be referenced. For standard fields, the Field Name must be used. For custom fields, the API Name must be used.
- City == 'Toronto'
- AnnualRevenue > 10000
- My_Custom_String_Field__c == 'ABC'
- My_Custom_Number_Field__c >= 123
Fields of the following types can be referenced. Formula fields that are defined as one of these types can also be referenced.
|
|
Using Fields
When comparing fields to literal values the values must be specified with specific formats so that they can be interpreted properly by the expression evaluator.
Checkbox
For checkbox fields, you can use the keywords True and False or the numbers 1 and 0.
- DoNotCall == True
- DoNotCall == 1
- HasOptedOutOfEmail == False
- HasOptedOutOfEmail == 0
Currency, Number, and Percent
Currency, Number and Percent fields are treated the same. They can be compared to various common number formats. Literal number values are specified without quotes.
- AnnualRevenue > 25000
- AnnualRevenue < 25000.00
- NumberOfEmployees < 10
- Probability > 66.7
Text, TextArea, Email, Phone, PickList, and URL
These fields are essentially handled the same way as generic strings. They can be compared to literal string values defined with single-quotes or double-quotes. In the case of phone numbers, literal values must be specified in the standard format or the format that is used to store the phone numbers in Salesforce.
- LastName == ‘Smith’
- LeadSource == ‘Web’
- Industry == ‘Agriculture’
- Email == 'support@vanillasoft.com'
- Phone == '(800) 345-6789'
- MobilePhone == ‘44 7836 191191’
- WebSite == 'http://www.vanillasoft.com'
Date, DateTime, Time
When comparing Date, Time and DateTime fields to literal values the values must be specified as strings. However, the literal values must be formatted in a specific way so that the expression evaluator can convert them to the matching field type. The string formats are as follows.
Type Value Formatting |
||
Date |
‘yyyy-MM-dd’ |
|
Time |
‘HH:mm’ or ‘HH:mm:ss’ |
24-hour format must be used |
DateTime |
‘yyyy-MM-dd HH:mm:ss’ |
24-hour format must be used |
- LastTransferDate == '2022-03-20'
- LastCURequestDate == '2022-02-14 21:20:00'
- DND_Start_Time__c == '18:00'
Using Operators
Comparison Operators
The following operators can be used to compare fields to literal values or to each other. The field type and value type must match in a comparison expression to achieve a valid evaluation. A single equal (=) will be accepted in place of a double equal (==).
Comparison Operators |
|||
== != > < |
Equal To Not Equal To Greater Than Less Than |
>= <= |
Greater Than or Equal To Less Than or Equal To |
Boolean Operators
The Boolean operators && (AND) and || (OR) are supported. They can be used to combine simple expressions to create more complex expressions. There is no operator for the Boolean NOT operation. The NOT() function can be used to accomplish the equivalent functionality. The Boolean values True and False can be specified with the literal values TRUE and FALSE. These values are case insensitive so True and False are also accepted. Additionally, when comparing Boolean values or expressions the numeric values 1 and 0 can also be used to represent True and False.
- City == 'Toronto' && HasOptedOutOfFax == FALSE && NOT(LeadSource == ‘Web’)
- State == ‘NY’ || State == ‘NJ’ || State == ‘CT’
- DoNotCall == False
- DoNotCall == FALSE
- DoNotCall == 0
Arithmetic Operators
There are six arithmetic operators are supported. These can be used to add arithmetic formulas to the trigger custom expression without creating formula fields.
Arithmetic Operators |
|||
+ - * / |
Addition Subtraction Multiplication Division |
% ^ |
Modulo Power |
- (Units_Sold__c - Units_Returned__c) > 10
- (Units_Returned__c / Units_Sold__c) < 0.1
- (Iqscore * Amount) > 500.0
Parentheses
Parentheses can be used to create boolean expressions with more complex conditions. They can also be used to ensure that the order of operations is evaluated properly. In some cases, even though they might not be required, they can be used to accentuate or clarify the operations in the expression.
- ((City == 'Toronto') || (City == 'Montreal')) && NOT(LeadSource =='SOLD')
- ((Units_Returned__c / (Units_Sold__c - Units_Cancelled__c)) < 0.5) && (State == 'NY')
Using Functions
There are three groups of functions that can be applied to field values or literal values: Matematic, String, and Specialty. The Mathematic functions assume that parameters to be of a numeric type. The String functions take a string type however if a field or value that is not a string type (Number, Datetime, Date, or Time) is specified the value will be converted to a string before the function is evaluated. The IsChanged() function can be used to limit trigger updates to occurring only when specified fields have changed.
Mathematic Functions |
|
Max(value1, value2) |
Returns the larger of the two specified values. |
Min(value1, value2) |
Returns the smaller of the two specified values. |
Abs(value) |
Returns the absolute value of the specified value. |
Round(value, places) |
Returns the value to the number of decimal places specified. |
Floor(value) |
Returns the largest integer less than or equal to value |
Ceiling(value) |
Returns the smallest integer greater than or equal to value |
String Functions |
|
Substring(string, start, length) |
Return the portion of the string beginning at the start index and having specified length. Parameters start and length must be integers. |
IndexOf(string1, string2) |
Return the position of the first occurrence of a string2 in a string1. If not found returns -1. |
Length(string) |
Return the length of the string. |
StringContains(string1, string2) |
Returns Tue if string2 is found anywhere in string1, otherwise return False |
StartsWith(string1, string2) |
Return True if string1 starts with string2. |
EndsWiths(string1, string2) |
Return True if string1 ends with string2. |
ToUpper(string) |
Return string converted to uppercase. |
ToLower(string) |
Return string converted to lowercase. |
Specialty Functions |
|
Not(expression) |
Return True if the expression evaluates as False, or False if the expression evaluates as True. |
IF(condition, value1, value2) |
Return value1 if the condition evaluates to True, otherwise return value2. |
IsChanged(field-name) |
Returns true if the specified field was marked as Changed during the operation that initiated the trigger. The field name must be specified as a literal string. For example, if we want to check the field City we would specify IsChanged('City'). If we want to check for custom field Units Sold we would specify IsChanged('Units_Sold__c'). |
Validation
Before a Cust Expression trigger can be saved it must be validated. This is done by clicking the Validate button below the Custom Expression text box. If there are any issues with the expression then a validation error explaining the issue will be displayed otherwise a message indicating the expression is valid will be displayed. After any newly created or modified customs expressions have been validated the Triggers can be saved.
Validation Error |
Successful Validation |