string Functions

Use string functions in rules to manipulate text strings in asset JSON at runtime.

For instance, a string function can replace all occurrences of one string with another or convert strings from uppercase to lowercase. If a user enters a dashboard title in the wizard using all lowercase letters, the string function changes the text to sentence case at runtime.

Parameters: Object object

Returns: Object

Recursive: Supported

Description: Converts all characters in an object to uppercase. The object can be a single string or a JSON object with multiple strings

This sample JSON:

And the rule:

Returns:

Parameters: Object object

Returns: Object

Recursive: Supported

Description: Converts all characters in a string to lowercase.

This sample JSON:

And the rule:

Returns:

Parameters: Object object, String oldStr, String newStr

Returns: Object

Recursive: Supported

Description: Returns a new object with all occurrences of oldStr replaced with newStr.

This sample JSON:

And the rule:

Returns:

Parameters: Object object, String regex, String newStr

Returns: Object

Recursive: Supported

Description: Replaces all substrings of this string that match the given regular expression.

This sample JSON:

And the rule:

Returns:

Parameters: Object object, String regex, String newStr

Returns: Object

Recursive: Supported

Description: Replaces the first substring of this string that matches the given regular expression.

This sample JSON:

And the rule:

Returns:

Parameters: Object object, String regex

Returns: Object

Recursive: Supported

Description: Parses a string and splits it into an array defined by the specified delimiter represented by the given regular expression.

This function call:

Results in array of strings:

Parameters: Object object, String regex

Returns: Object

Recursive: Supported

Description: Performs complex regular expression matching and returns an array of matching results.

To capture items surrounded by square double quote and square brackets:

Returns the following array:

Parameters: Object object, String delimiter

Returns: Object

Recursive: Supported

Description: Creates a string from an array of strings and separates each item by the specified delimiter.

This function call:

Results in:

Parameters: String name

Returns: String

Recursive: Not supported

Description: Adds a Salesforce namespace and the __ delimiter to a given name if a namespace is available. If there is no namespace, the name is returned without alteration.

This sample JSON:

With:

Returns:

Parameters: Object object, int length

Returns: Object

Recursive: Supported

Description: Returns the hash value for the given string. Useful for determining Salesforce ID lengths and uniqueness. Uses the SHA-256 algorithm to determine the hash value.

This function call returns a truncated hash value:

Results in: