Data manipulation with Pega Robot Studio utilities
String, DateTime, and File utilities
Pega Robot Studio™ provides utility components to manipulate and format data values for strings, datetimes, timespans, and files. The Utility components are similar to components available in the Microsoft .NET Framework. The components are accessible from the Advanced section of the Toolbox window. To add a utilities component, drag the component to an automation or a Global Container. Select the required method of the component from the Object Inspector and add the method to the automation.
The StringUtils component provides a comprehensive selection of string manipulation methods. The component uses the StringValue input parameter to specify the string for which you want to apply a method. The methods include Concat, IndexOf, Trim, Insert, Replace, and so on.
In the following example, the automation extracts the substring of a string input value. The substring starts at the fifth index position in the string input.
DateTimeUtil and TimeSpanUtils
Use the DateTimeUtil component to manipulate an instant in time, typically expressed as a date and time of day. Use TimeSpanUtils to manipulate a time interval. Pega Robot Studio provides additional methods besides those from the Microsoft .NET Framework.
In the following example, the ToString method is used to convert a DateTime value to a String type for use in a String Expression component.
To manipulate directories and files, use the FileUtils component. The FileUtils methods expose corresponding .NET methods. When implementing the FileUtils, do not include invalid path characters or lengths in the path parameters and be sure to comply with all security and data protocols. Unauthorized access or I/O exceptions prevent the system from executing the selected method.
In the following example, the automation uses the Move method of the FileUtils component to move the directory of a file.
If the FileUtils component does not appear in your Pega Robot Studio toolbox, you can add the component by using the Choose Toolbox Items window.