Token Editor

The Token Editor lets you modify token values with functions, regular expressions, indexing, and formatting. These editing options are also available in the Token Dialog.

To open the Token Editor

  1. When modifying the properties of a workflow activity, right-click any token that appears in a text box.
  2. Select Token Editor.

Example: Bill wants to rename entries with the current month and year. In the Rename Entry activity's New Entry Name property box, he selects the Date token by clicking the Token button (right arrow) . Because the Date token is replaced by the current month, day, and year, Bill needs to modify the token so it only returns the month and year. To access the token editing options, he right-clicks the token and selects Token Editor.

To use the Token Editor

  1. In the Token Editor select one or more of the following options: Apply Function, Apply Index, Apply Formatting, and/or Apply Regular Expressions.

Note: Operations in the Token Editor are applied in the following order: function, index, formatting, regular expression.

    • Apply Function: This feature lets you edit the token value with one or more pre-configured operations.
      • Average: Determines the average of all the values in a multi-value token and replaces the token with the average. Non-numeric values will be ignored.
      • Encode URI: Converts a token's characters (except RFC 2396 unreserved characters) to their hexadecimal representation so the token can be used in a web address. More info.
      • Example: If you apply this function, http://My Website.com will be converted to http://My%20Website.com. You may want to use this function with tokens used in the HTTP Web Request and HTTP Form Post activities so the URLs resolve correctly.

      • Encode URL: Converts a token's characters (except RFC 3987 unreserved characters) to their hexadecimal representation so the token can be used in a web address. More info.
      • Example: If you apply this function, ?parameter1=1&1parameter2=2 will be converted to %3Fparameter1%3D1%26parameter2%3D2. This activity will convert more characters than Encode URI

      • Encode XML: Allows you to escape XML characters, such as <, >, ", ', and &, and replace them with their encoded values. Choose this option if your token includes XML characters that you want to display as text in e-mails or other places. If you do not encode the XML with this function, e-mail clients may try to interpret the XML instead of simply displaying the text.
      • Example: If you apply this function, <tag> will display as &lt;tag&gt;;.

      • Max: Determines the largest value in a multi-value token and replaces the token with the largest value.
      • Min: Determines the smallest value in a multi-value token and replaces the token with the smallest value.
      • Remove Duplicates: Removes duplicate values from multi-value tokens.
      • Remove Empty Items: Removes empty values from multi-value tokens.
      • Sort Ascending: Organizes the values in a multi-value token from smallest to largest.
      • Sort Descending: Organizes the values in a multi-value token from largest to smallest.
      • Split: Divides a single-value token into a multi-value token. The single-value token is divided whenever a specified character or characters appears in the token. When you apply this function, a text box appears for you to specify the characters the token will be divided at. Alternatively, click the Token button (right arrow) to use a token in your delimiter.
      • Example: If the token's value is "Jan;Bob;Sue" and you specify ";" as the delimiter, then the result of this function will be a token with three values: "Jan ", "Bob ", and "Sue ". If the token's value is Animal Control Department Health Department Human Resources Department Accounting Department, and you specify "Department" as the delimiter, the resulting multi-value token will have four values: "Animal Control ", " Health ", " Human Resources ", and " Accounting ".

        Tip: The split function adds a blank space at the end of each value. Additionally, if the single-value token has spaces between the delimiter and the next value those spaces will be retained. Combine this function with the "Trim" function to remove those extra spaces from the multi-value token.

        You can also split a token function using control characters. You can enter one of the following control characters into the Split on box to split a token into a multi-value token:

        Control Character Description
        #CR# Split on carriage return (for the older mac style)
        #NL# Split on new line/line feed (unix style)
        #LF# Split on new line/line feed (unix style)
        #CRNL# Split on carriage return and new line (windows style) Note: order matters
        #CRLF# Split on carriage return and new line (windows style) Note: order matters
        #NLCR# Split on new line and carriage return (windows style) Note: order matters
        #LFCR# Split on new line and carriage return (windows style) Note: order matters
        #TAB# Split on tab
        #NEWLINE# Split on new line (windows style), new line/line feed(unix style), and carriage return (for the older mac style)
        #\r# Split on carriage return (in C-style syntax)
        #\t# Split on tab (in C-style syntax)
        #\n# Split on newline (in C-style syntax)
        #\r\n# Split on carriage return and new line (in C-style syntax) Note: order matters
        #\n\r# Split on new line and carriage return (in C-style syntax) Note: order matters

        When you apply one of these control characters, you should see the following syntax (this example uses #NEWLINE#): %(Token 1#@Split(#NEWLINE#)@#)
      • Sum: Adds together all the values in a multi-value token and replaces the token with the sum.
      • Text Length: Counts the number of characters in the token's value and replaces the token with this number.
      • Example: Work Request forms require that employee's last names be no more than 10 letters. By applying the Token Length function to the %(Last Name) token, you can count how many letters are in the employee's last name. Using a Conditional Sequence activity (to check for Last Name tokens with a value larger than 10) and a Pattern Matching activity, you can truncate all employee last names that are longer than 10 letters.

      • To Lower: Converts all letters in the token's value to lowercase.
      • To Title Case: Capitalizes the first letter of each word in the token to uppercase. If a word in the token is all capital letters (like an acronym) it will not be affected by this function. If there is a capital letter in the middle of the word, it will convert that letter to lowercase (i.e., "helLo" will be converted to "Hello," and "O'Neil" will be converted to "O'neil.")
      • Tip: If your token is in all capital letters and you want to convert it to title case, first apply the "To Lower" function and then the "To Title Case" function.

      • To Upper: Converts all letters in the token's value to uppercase.
      • Trim: Removes any white spaces before or after a token's value.
      • Value Count: Counts the number of values in a multi-value token and replaces the token with this number.

      To apply functions, click the Select function link, and, in the Token Function dialog box, move the functions you want to apply to the token from the left Available column to the right Applied column by clicking the green right arrow . Functions will be applied to the token in the order they appear in the right column. You can change the order by selecting the function you want to move and using the green up-and-down arrows . Click OK to return to the Token Editor.

    • Apply Index: For tokens that accept multiple values, you can have the token be replaced by one of the values or all the values separated by one or more characters.
      • The value at index: To specify which value a multi-value token will be replaced by, type the value's index number in the text box or using the scroll up-and-down arrows . Alternatively, click the Token button (right arrow) to specify an index using tokens. Values are given an index number according to the order in which they are added.
        • By default, this editor will count the values from the start of a multi-value list.
        • Example: Typing in an index value of 1 will retrieve the 1st value in the list (the oldest value), typing in an index of to 2 will retrieve the 2nd value, etc. To retrieve a value near the end of the list, click the start link to change it to end. When the link says end, the indices will count from the end of the list. Therefore, typing in an index value of 1 will retrieve the last value in the list (the newest value); typing in an index value of 2 will retrieve the second to last value, etc.

        Note: If you are counting values from the start and you specify an index greater than the total number of values in the token, the token will be replaced by the last value. If you are counting values from the end and you specify an index greater than the total number of values in the token, the token will be replaced by the first value.

        Note: If you type a character or string of characters other than an integer or a token in this text box, none of the token's values will be extracted. Instead, the All values separated by option below will be selected and the character(s) will be used to separate each token value.

      • All values separated by: This option will have the token be replaced by all values, separating them by one or more specified characters. Type one or more characters in the text box next to this option, or select a character from the drop-down menu.
    • Apply Formatting: You can apply formatting to tokens so that the information that replaces them will be automatically presented in a specific way, such as in a certain date format, a percentage, a currency, a decimal, a specific number of digits, etc. The standard for formatting a token is %(token,"expression"), where token is the name of the token and expression is a .NET formatting expression. More information.
    • Apply Regular Expression: This feature lets you modify the token value using regular expressions. Click the pattern matching button to select from a list of regular expressions.
  1. Optional: Test your token. After applying a token function, regular expression, index, or formatting, click the Click here to test the token link. In the Test Value box, type in one or more sample token values. (You can test a multi-value token by typing values on multiple lines.) The Result Value box will show how the options you configured above will affect the token's value.
  2. Click OK.