Format the text by using variable placeholders and line and tab variables with the Format Text component in RPA Desktop Design Studio. You can update the text and their positions easily by just updating the variable placeholders and the line and tab variables.

Before you begin

Role required: none

About this task

Common issues and solutions for using the Format Text Component.

Missing Arguments

This issue occurs when the format string contains more placeholders than the number of arguments provided.

For example,
  • Format string: {0} {1}
  • Arguments provided: "Hello"
The error message displayed for this issue is "An error occurred during execution. Component 'Format Text' failed to execute in the activity 'New Activity'."

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

The solution is to ensure the number of arguments matches the number of placeholders in the format string:

"Hello"

"World"

Correct Argument Placement

The index (zero-based) must be greater than or equal to zero and less than the size of the argument list.

Solution:

The solution is to ensure the number of arguments matches the number of placeholders in the format string. For example:

  • Format String: "Hello"
  • Argument: "World"

In this case, the format string does not contain any placeholders, so no arguments are needed. If you have a format string like "Hello, {0}! Welcome to {1}.", you would need to provide two arguments, such as "World" and "ServiceNow".

Using Literal Curly Braces in Format Strings

Issue: Curly braces {} have special meaning in string formatting and must be escaped when used as literal characters.

Example of Incorrect Usage:

Format String:

{
{0}
{1}
},

Error Message: An error occurred during execution. Component 'Format Text' failed to execute in the activity 'New Activity'.

Input string was not in a correct format
The solution is to use double braces to represent literal curly braces:

{{
{0}
{1}
}},
Rule to remember:
  • {{ represents a literal {
  • }} represents a literal }

You can configure the properties for the Format Text component. For more information about these properties, see Properties of the General components.

Procedure

  1. In the Toolbox pane, navigate to General > Format Text.
  2. Drag the Format Text component to the Design surface.
  3. To set the text placeholder variable, do the following steps.
    1. Click the add variable icon (Add variable icon.).
      A Data In port is added for each variable you add.
    2. To configure the variable value, see Configure port properties.
    3. (Optional) Repeat the steps to add more variables and values.
  4. Click the component settings icon (Component settings icon.).
  5. Insert the text in the TEXT FORMAT EDITOR.
  6. Insert the text.
  7. (Optional) Insert the line separator \n or tab separator \t variable at appropriate places within the text.
  8. Insert the text variable placeholders within the text body, wherever appropriate.
    Tip: To update the text, update the placeholder value.
  9. Connect the data and control ports of the Format Text component to the corresponding ports of the other component as described in the following table.
  10. (Optional) To test the component, under the DESIGN tab, click Run.