Validating Fields on Forms
Frontend validations is a part of the InCountry Data Residency for Salesforce package. The package utilizes native Salesforce validation rules and use them to validate data inputs against the specified criteria. The InCountry Data Residency for Salesforce package pulls the error condition formulas from native validation rules and re-uses them to validate input data at the frontend side.
Setting up validation rules
For the details on how to create and configure validation rules, please check Salesforce documentation.
You need to disable a native validation rule if you migrate it to InCountry frontend validations. Due to usage of hash function, native validation rules may work incorrectly or throw an error due to replacement of clear-text values with their hashes.
When using frontend validations in Experience Cloud, ensure that the Validation_Rule__c
object has the Public Read permission for the Default External Access in the sharing settings.
Synchronizing and activating frontend validations
-
In the App Launcher form, select InCountry.
-
Select Settings.
-
Select the Salesforce object for which you want to synchronize the created validation rule.
-
Expand the Frontend Validations section.
-
Click the down arrow icon on the rule you want to synchronize to expand the list of actions within it.
-
Click Synchronize.
-
Click Activate.
Once the synchronization of the validation rule and activation of a frontend validation are complete, the following validation will be applied to the record create/edit operation when you submit the form.
You save a new or modified record, the assigned frontend validations will be executed. They will use the error condition formula to verify the input values against specific criteria. If validation fails, you will see a corresponding error message. If validation passes, a record will be saved successfully.
Supported system objects
The following system objects are supported/not supported in the Error Condition Formula text box:
Object | Supported | Field restrictions |
---|---|---|
$User | The 'LanguageLocaleKey' , 'LocaleSidKey' , 'TimeZoneSidKey' fields should be populated as key values in the error condition formula. Standard Salesforce validation rules can support both 'en_US' , and 'English' , but since the field values are retrieved through a SOQL query, the only value returned is the key value 'en_US' and we can use only this value.The 'StartDay' and 'EndDay' fields are not supported by the rules since it is not possible to obtain values for these fields through a SOQL query. This is a Salesforce limitation. | |
$UserRole | - | |
$Organization | - | |
$Profile | - | |
$CustomMetadata | - | |
$Label | - | |
$ObjectType | - | |
$System | - | |
$Setup | - |
Supported formula functions
Functions | Description |
---|---|
DATE & TIME | |
| Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date. |
| Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year. |
| Returns a year, month, day, and GMT time value. |
| Returns a date value for a date/time or text expression. |
| Returns a day of the month in the form of a number from 1 through 31. |
| Returns the local time hour value without the date in the form of a number from 1 through 24. |
| Returns a value in milliseconds in the form of a number from 0 through 999. |
| Returns a value in minutes in the form of a number from 0 through 60. |
| Returns the month, a number between 1 (January) and 12 (December) in the numeric format of a given date. |
| Returns a date/time representing the current moment. |
| Returns a value in seconds in the form of a number from 0 through 60. |
| Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date. |
| Returns the local time value without the date, such as business hours. |
| Returns the current date as a date data type. |
| Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday. |
| Returns the four-digit year in number format of a given date. |
LOGICAL | |
| Returns a |
| Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression. |
| Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any values, it returns the |
| Determines if expressions are true or false. Returns a given value if true and another value if false. |
| Determines if an expression has a value and returns |
| Checks if the formula is running during the creation of a new record and returns |
| Determines if an expression is null (blank) and returns Use |
| Determines if a text value is a number and returns |
| Returns |
| Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression isn’t blank, returns the value of the expression. Use |
| Determines if expressions are true or false. Returns |
| Returns the previous value of a field. |
MATH | |
| Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign. |
| Rounds a number up to the nearest integer, away from zero if negative. |
| Returns a value for e raised to the power of a number you specify. |
| Returns a number rounded down to the nearest integer, towards zero if negative. |
| Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904. |
| Returns the base 10 logarithm of a number. |
| Returns the highest number from a list of numbers. |
| Rounds a number up to the nearest integer, towards zero if negative. |
| Rounds a number down to the nearest integer, away from zero if negative. |
| Returns the lowest number from a list of numbers. |
| Returns a remainder after a number is divided by a specified divisor. |
| Returns the nearest number to a number you specify, constraining the new number by a specified number of digits. |
| Returns the positive square root of a given number. |
TEXT | |
| Determines if text begins with specific characters and returns |
| Converts a 15-character ID into a case insensitive 18-character ID. |
| Compares two arguments of text and returns |
| Returns the position of a string within a string of text represented as a number. |
| Determines if any value selected in a multi-select picklist field equals a text literal you specify. |
| Determines if any value selected in a multi-select picklist field equals a text literal you specify. |
| Returns the specified number of characters from the beginning of a text string. |
| Returns the number of characters in a specified text string. |
| Converts all letters in the specified text string to lowercase. Any characters that aren’t letters are unaffected by this function. Locale rules are applied if a locale is provided. |
| Inserts characters you specify to the left-side of a text string. |
| Returns the specified number of characters from the middle of a text string given the starting position. |
| Returns the specified number of characters from the end of a text string. |
| Appends characters to the right side of a text string. |
| Substitutes old text with new text in a text string. |
| Converts a percent, number, date, date/time, or currency type field into text wherever formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links. |
| Removes the spaces and tabs from the beginning and end of a text string. |
| Converts all letters in the specified text string to uppercase. Any characters that aren’t letters are unaffected by this function. Locale rules are applied if a locale is provided. |
| Converts a text string to a number. |
ADVANCED | |
| Compares the value of a field to the previous value and returns |
| Compares a text field to a regular expression and returns All the single quotes must be escaped. The correct way of escaping single quotes: |
Management of frontend validations
Icon | Description | Available actions |
---|---|---|
The Salesforce validation rule is found but not synchronized with InCountry frontend validations. | You can only synchronize the record or edit it. The edit action leads to the original Salesforce rule. | |
The Salesforce validation rule is synchronized with InCountry frontend validations and up to date with the Salesforce rule. | You can use the buttons activate, deactivate, delete (It affects only synchronized rules, activation/deactivation or deletion of synchronized rules has no effect on Salesforce validation rules). The edit action leads to the Salesforce rule. | |
This means that the original Salesforce validation rule was updated after the rule was synchronized with the InCountry frontend validation. | You can perform all actions on the synchronized rule and re-synchronize the rule to make it up to date with the InCountry frontend validation. |
-
If the original Salesforce validation rule is deleted, you cannot edit the rule, only activate/deactivate/delete.
-
If you delete a synchronized frontend validation, the original validation rule will be shown in place of the deleted one. The synchronization status is displayed as
unsynchronized
. You can synchronize it again.