Set Variable

<< Click to Display Table of Contents >>

Navigation:  Trigger Actions > Available Action Types > File Operations, Set Variable, Misc >

Set Variable

Creates and/or sets a ThinkAutomation Global Variable.

 

action-set

 

In addition to Extracted Fields you can also make use of 'Variables' in your ThinkAutomation Actions.

 

A Variable is simply a place holder for a specific value. Variables maintain their values between each message processed - whereas Extracted Fields are reset on each new message.

 

Some other ThinkAutomation Actions (such as Save Attachments, Read A Web Page etc) can return values which can be assigned to Variables. In these cases you must create the Variable first by simply dragging into the Actions list and giving it a name BEFORE you want use it in other Actions.

 

Each Variable must be given a Variable Name.

 

You can optionally assign it a Value. The Value can be a fixed value or the value of another Extracted Field or Variable (using %field% replacements). See: Using Field Replacements

 

The Operation option allows you to perform an optional additional operation on the Value before it's assigned to the Variable.

 

The available Operations are:

 

Increment

Adds 1 to the current value of the Variable.

Decrement

Subtracts 1 from the current value of the Variable.

Add To

Adds the value specified in the Value property to the current value of the Variable.

Subtract From

Subtracts the value specified in the Value property from the current value of the Variable.

Add Days To

If the existing value is a date then adds the days specified in the value to the existing date value.

Subtract Days From

If the existing value is a date then subtracts the days specified in the value to the existing date value.

Convert To Upper Case

Converts the Value to UPPERCASE.

Convert To Lower Case

Converts the Value to lowercase.

Trim Blanks

Removes leading and trailing blanks from the Value.

Remove All Whitespace

Trims and removes all whitespace (multiple spaces, tabs, line feeds, carriage returns) are converted to single spaces.

Remove First & Last Characters

Trims the first and last characters (useful for removing quotes or brackets from a string).

Add Space Character To End

Adds a space character to the end of the Value if a space does not already exist (useful when concatenating names).

Word Capitalize

Converts to lowercase then Capitalizes each word in the Value.

Convert HTML To Plaintext

If the Value is HTML then all tags are removed.

Convert HTML To XML

If the Value is HTML then the text is converted to well-formed XML.

Extract First Email Address

The Variable is set to the first email address found in the Value.

Extract All Email Addresses

Extracts all email addresses found in Value. Returns comma separated list.

Extract First URL

Extracts the first URL (web address) found in the Value.

Extract All URL's

Extracts all URL's found in Value. Returns comma separated list.

Encrypt

Encrypts the Value using 128 bit AES encryption. The resulting value is URL encoded.

Decrypt

Decrypts the Value using 128 bit AES encryption using the same key as the Encrypt operation.

URL Encode

URL Encodes the Value.

URL Decode

URL Decodes the Value.

Base 64 Encode

Base 64 Encodes the Value.

Base 64 Decode

Base 64 Decodes the Value.

Quoted Printable Encode

Quoted Printable Encodes the Value.

Quoted Printable Decode

Quoted Printable Decodes the Value.

Create MD5 Hash

Creates an MD5 Hash of the Value which is then URL encoded.

Create GUID

Generates a Globally Unique Identifier.

Domain From Email Address

Finds the first Email Address in Value and extracts the domain part (after the @).

Alias From Email Address

Finds the first Email Address in Value and extracts the alias part (before the @).

Compress

Compresses and base64 encodes the Value.

Decompress

Decompresses the base64 encoded Value.

Convert Plain Text To HTML

Replaces all line-feed characters with <br />, encodes special characters and encloses any URLS or email addresses in <a> tags.

Filename Only

Extracts just the file name from a full path. Eg: C:\Folder\filename.txt becomes filename.txt

Directory Only

Extracts just the directory from a full path. Eg: C:\Folder\filename.txt becomes C:\Folder\

 

If the Append To Existing Value option is enabled then the Value will be appended to the existing value for the Variable. Care should be taken using this if the Variable is persisted and is not cleared at some point - to avoid ending up with very big strings.

 

If the Initialize With Existing Value option is enabled the the Variable value will set to the previous value saved from the last processed message if the assign Value is blank.

 

Note: ThinkAutomation sets a size limit 10MB for each global variable instance.

 

 

Database Lookup Variables

You can also assign it using a Database Lookup.

 

When using a Database Lookup you create a Database Connection String and SQL Select statement to lookup a value from an external database.

 

action-set-lookup

 

The Return Field is set to the field in the SELECT statement that you want to return the data for and assign to the Variable.

 

 

Setting A Variable Value Using A Script

You can assign a variable value using a script. Click the Set Via Script tab.

 

action-set-script

 

Enable the Set The Value Using A Script option and click the Edit button to edit the script.

 

The script editor will then open. In the script set the ThinkAutomationVariable property to the value you want assigned to the variable. The property will be pre-assigned to the variables current value. You can use the script to adjust or override the value using any script you choose.

 

 

ThinkAutomation © Parker Software 2016