The Character functions action provides a way to manipulate and parse text.
In each function, there are parameters to specify the source of the text. Since the text source can be stored in a variety of different places within Method, a dropdown is provided to locate where the text can be retrieved. This can range from text being manually typed in, to text in action results or controls on screen.
The result of the Character function can be stored in an action result or a control on screen.
In this article, we will cover the following functions:
Find in Json
Function Returns: The value within a JSON given a key.
JSON (JavaScript Object Notation) is a format for structuring data. It is used to transmit data between a server and a web application and normally returned from a Call Web Service Action.
▶ JSON text: the JSON text to parse (do not included quotations).
▶ Find value for key: the key to reference the value.
▶ Store Result in: where to store the value referenced by the key.
NOTE: When finding a value for a key, the text to find must match exactly as shown in the JSON. This includes the case of the letters: uppercase and lowercase.
JSON Examples
JSON can be tricky because of the many ways to nest values within it. For this example, we will search through the following JSON text:
{"topk1": {
"k2": "v2",
"k3": {
"k3sub": "v3sub"
},
"k4": {
"k4Array": [
{"k4a1": "v4a1", "k4a2": "v4a2"},
{"k4b1": "v4b1", "k4b2": "v4b2"},
]
}
}}
To find the value of a key, you need to prepend every parent of that key, connected with a period.
For example, when the key is
topk1.k2
, the value returned isv2
.When key is
topk1.k3.ksub3
, the value returned isv3sub
.
If you ask for the value of a key that has nested keys and values, you will get all of the text enclosed in brackets.
When key is
topk1.k3
, the value returned is this subset of the JSON:{
"k3sub": "v3sub"
}When key is
topk1
, the value returned is the rest of the text with brackets:{
"k2": "v2",
"k3": {
"k3sub": "v3sub"
},
"k4": {
"k4Array": [
{"k4a1": "v4a1", "k4a2": "v4a2"},
{"k4b1": "v4b1", "k4b2": "v4b2"},
]
}
}
You can use this to your advantage by saving this into an Action Result, and using another Find in JSON function on that subset.
Arrays get a bit trickier. When the key is topk1.k4.k4Array
, the value returned is the entire array:
[
{ "k4a1": "v4a1", "k4a2": "v4a2" },
{ "k4b1": "v4b1", "k4b2": "v4b2" }
]
To grab the values of the array, you will need to index the arraying using square brackets, starting at zero:
topk1.k4.krArray[0]
returns{ "k4a1": "v4a1", "k4a2": "v4a2" }
topk1.k4.krArray[1]
returns{ "k4b1": "v4b1", "k4b2": "v4b2" }
To get the individual elements of the array, you will need to include it in your key value query:
topk1.k4.krArray[0].k4a1
returns the valuev4a1
.topk1.k4.krArray[0].k4a2
returns the valuev4a2
.topk1.k4.krArray[1].k4b1
returns the valuev4b1
.topk1.k4.krArray[1].k4b1
returns the valuev4b2
.
Find in Text
Function Returns: The numerical position of some text within a larger body of text.
▶ Find the: select either the First or the Last occurrence of the text you want to find.
▶ Occurrence of: the text you want to find.
▶ Inside the text: the body of text to search through.
▶ Starting at character: where in the body of text to start searching through.
▶ Store Result in: where to store the position of the found text.
Find in Text Examples
The below sentence will be used for the following examples. For reference, the numbers indicate the position for those letters in the sentence.
First occurance of "fox" starting at character 1 will result in
17
.Last occurance of letter "o", starting at character 1 will result in
42
.
Is Email Address
Function Returns: True or False depending on the result.
▶ Is this an email address? : provide an email or a comma-separated list of emails.
▶ Store Result in: where to store the true or false result.
Is Date / Empty / Numeric
Function Returns: True or False depending on the result.
▶ Is this a date/empty/a number? : the text you want to test.
▶ Store Result in: where to store the true or false result.
Join
Function Returns: Text created from the joining of provided texts.
▶ Join this: the first piece of text you wish to join
▶ With this: the second piece of text you wish to join
⊕ Add another join: bring up another field to join more text
▶ Separate joins with: in between the joined texts, you can insert
Custom text
Comma [
,
]New Line
No Separator
Space []
Pipe [
|
]
▶ Store Result in: where to store the final text result
Join Example
In this example, we will use two words to join:
Join this:
first
With this:
second
and display what each looks like with each separator:
Custom text (i.e. "myWord"):
firstmyWordsecond
Comma:
first,second
New Line:
first
secondNo separator:
firstsecond
Space:
first second
Pipe: :
first|second
Left
Function Returns: Extracted text from a given text.
▶ Extract text from: the text to extract from.
▶ Search using Position | Return this many characters starting from the left:
Return stated number of characters starting from the beginning of the text.
Example: If the original text is "abcde" and 2 characters are set to be returned, then the result is "ab".
▶ Search using Text | Return all characters before this:
Return all characters before stated search text.
Example: If the original text is "abcde" and we set the text to "de", then the result is "abc".
▶ Store Result in: where to store the final text result.
Right
Function Returns: Extracted text from a given text.
▶ Extract text from: the text to extract from.
▶ Search using Position | Return this many characters starting from the right:
Return stated number of characters starting from the end of the text.
Example: If the original text is "abcde" and 2 characters are set to be returned, then the result is "de".
▶ Search using Text | Return all characters after this:
Return all characters before stated search text.
Example: If the original text is "abcde" and we set the text to "bc", then the result is "de".
▶ Store Result in: where to store the final text result.
Middle
Function Returns: Extracted text from a given text
▶ Extract text from: the text to extract from.
▶ Search using Position: extract text based on a numeric position.
Return this number of characters: How many characters to return.
Starting at position: numerical position to start.
Example: If the original text is "abcde", and we want to 2 characters starting at the 3rd position, then the result would be "cd".
▶ Search using Text: return text between two text values.
Return characters between this: Start extraction after this text.
And this: Complete extraction before this text.
Example: If the original text is "abcde", and we want to return characters between "ab" and "de", then the result would be "c".
▶ Store Result in: where to store the final text result.
Length
Function Returns: The number of characters in a given text.
▶ Return the number of characters in: the text to count characters.
▶ Store Result in: where to store the final count.
Replace
Function Returns: the text with replacements specified.
▶ Within text: the text to update with replacements.
▶ Replace this: the text to search for.
▶ With this: the replacement text.
▶ Store Result in: where to store the final text result with replacements.
Replace Example
If Within text is
I read the book "{{TITLE}}".
And Replace this is set to {{TITLE}}
,
While With this is set to The Little Prince
,
Then the result will be:
I read the book "The Little Prince".
Note the use of the curly brackets: {{}}. This is to ensure no other word with the text of TITLE
would accidentally be replaced.
Replace Merge Fields
Function Returns: the text with merge fields replaced
A merge field allows you to pull in field values from a table to be put into text, often used for email templates. For example, here is some text with a merge field:
Dear Contacts.Name,
It was good to meet you.
The merge field is Contacts.Name. The first part before the period specifies the table, "Contacts" and the second part refers to the field in the table "Name".
Given a Record ID to specify a particular record, the merge field in the above text will be replaced with the value taken from the Name field of that record in the Contacts table.
▶ Using This Text: the text with the merge fields.
▶ Merge Data from This Table: the table to retrieve values from.
▶ Using this RecordID: the record id of the record to retrieve values from.
▶ Store Result in: where to store the final text result with replacements.
Merge Field Example
In this example, we want to merge Amy Ford's contact information. Note that her RecordID is 3, which uniquely identifies Amy Ford's record.
Now we will use this body of text for the Using This text field:
Dear Contacts.FirstName,
It was good to meet you. Is this your correct phone number?
Contacts.Phone
When we use the Record ID of 3, which identifies Amy Ford, it will pull in the two pieces of data that corrpespond to the merge fields. The resulting text would be:
Dear Amy,
It was good to meet you. Is this your correct phone number?
(630)555-3393
To Upper/Lower/Title Case
Function Returns: the text changed to the specified case
The three functions mentioned are:
▶ Lower case: all text is converted so there are no capital letters.
▶ Upper case: all text is converted to capital letters.
▶ Title case: each word is capitalized.
▶ Convert this to lower/upper/title case: the text to convert.
▶ Store Result in: where to store the final text result.