Extending published Application Assets
4 Tasks
30 mins
Scenario
You are a Robotics software development team member currently working on an application asset dedicated to the Pega Finance application. Your task is to update the Finance Asset project with a new helper method, which translates the two-letter state abbreviations to the state names for the Add Customer form, which is required when adding a new customer.
You were provided with the application documentation and project documentation that states the following:
- To access the application, open the following link: https://roboticstraining.pega.com/
- Use the following credentials to log in to the Finance application:
User name Password pega pega - The Add Customer form requires a full state name to successfully add a customer.
- The provided file contains a dictionary of state names and their abbreviations used in the application method:
States.zip (708 bytes)
Complete the following tasks:
- Create the private application method framework with output and input parameters. The method should have a String input parameter representing the state abbreviation and a String output parameter representing the full state name. It should also contain output parameters consistent with the application asset implementation for error handling.
- Update the application method with basic checks for the input parameter. Use the Toolbox methods to check if the input parameter is two digits long. Optionally, check if the input parameter consists of upper-case characters only.
- Create a lookup table component that includes state abbreviations and their corresponding state names. Since the method you create will serve as a helper, add the lookup table component to the Asset globals.
- Update the abbrToState application method to utilize the global lookup table for translating the state abbreviations. First, add the dictionary text file provided in the scenario to the Miscellaneous folder within your project. Use the Toolbox methods to obtain the file path and import the text file into the lookup table component. Finally, utilize the lookup table's method to perform the conversion.
Challenge Walkthrough
Detailed Tasks
1 Create a lookup table containing state abbreviations and corresponding state names
- In the File Explorer open the Pega Robot Studio installation folder, and then navigate to Extra Resources\Sample automation projects.
- Copy and unzip the Finance Asset Project to the desktop folder.
- Open the project in Pega Robot Studio.
- Click the Finance tab, and then switch to the Interface tab.
- On the Interface tab, click Asset globals.
- On the Asset globals, in the Toolbox search field, enter LookupTable.
- Drag the LookupTable component to the globals.
- In the property grid, update the Name property to StateAbbreviations.
- In the property grid, click the More icon on the Fields property to open the LookupField Collection Editor.
- In the LookupField Collection Editor, click the Add icon to add the following fields to the lookup table:
AutoIncrement FieldName Key Type False Abbreviation True System.String False State False System.String - In the Collection Editor, click to finish editing.
- On the toolbar, click to save the project.
2 Create the application method framework with output and input parameters
- In Project Explorer, click and open the Finance application.
- Click the Interface tab.
- In the Methods section, click the + icon to add a new method.
- In the Add new application method dialog box, name the abbrToStateName method, and then clear the Empty automation checkbox.
- Click to create a new application method.
- In the Entry Point, use the + icon to add the String parameter named StateAbbr.
- In the ExitPoint design block, use the + icon to add the String parameter named State.
- In the Exit design block, use the + icon to add the String parameter named State, and then connect the data output to the corresponding parameter of the ExitPoint.
- On the design surface, connect the links as shown in the following figure:
- On the toolbar, click Save to save the automation.
3 Update the application method with basic checks for the input parameter
- Add the following design blocks to the abbrToStateName automation surface to check if the input parameter is two digits long:
Design block name Location Connections Length method
Toolbox > Data handling > Strings > Status Automation link: Entry point - Length method
Data link: StateAbbr - stringValue
Equals component
Toolbox > Workflow > Decisions
Parameter value: 2Automation link: Length method - Equals component Convert abbreviation label
Context menu > Add > Label JumpTo Convert abbreviation
Context menu > Jump To > Convert abbreviation Automation link: Equals component > Jump To Convert abbreviation - In the Jump To Error design block, click Enter error message, and then enter Invalid abbreviation length.
- On the automation surface, connect the design blocks as shown in the following figure:
- On the toolbar, click Save to save the automation.
- Optional: Update the application method with additional input parameter checks.
After running tests on the application assets, the Quality Assurance team pointed out the following scenarios:
-
Check if the state abbreviation contains letters only,
-
Check if the state abbreviation contains capital letters only.
Use the existing methods from the Toolbox to fulfill the requirements.
4 Update the abbrToState application method to use the asset global lookup table to translate the abbreviation
- Download the States.zip file, unzip the contents of the States.zip file, and place them in your project’s Miscellaneous Files folder.’
- In Pega Robot Studio, click and open the Finance.abbrToStateName tab.
- Add the following design blocks to the automation surface to determine the path of the dictionary file:
Design block name Location/Parameters Connections GetProjectPath method
Toolbox > Runtime > Runtime Automation link: Convert abbreviation label - GetProjectPath method GetParentDirectory method
Toolbox > Data handling > Files > Path Automation link: GetProjectPath > Result - GetParentDirectory method CombinePaths method
Toolbox > Data handling > Files > Path
Parameter value: paths1 = Miscellaneous Files\States.txt
Automation link: GetParentDirectory method - CombinePaths method
Data link: GetParentDirectory > Result - CombinePaths method
- Add the following design blocks to import the dictionary file to the lookup table and retrieve the record from it:
Note: If the Asset globals section is not available in Palette, close and reopen the application method tab.Design block name Location Connections ImportDelimitedFile method
Palette > Asset globals > StateAbbreviations
Parameters value:
delimiter = Comma
mappingMethod = UseColumnIndexAutomation link: CombinePaths method - ImportDelimitedFile method
Data link: CombinePaths > Result – ImportDelimitedFile > filePath
GetRecord method Palette > Asset globals > StateAbbreviations Automation link: ImportDelimitedFile > Result > True – GetRecord
Automation link: GetRecord > Result > True – Jump To Exit
Data link: GetRecord > State – Jump To Exit > State
StateAbbr property
Palette > Locals > Run Data link: StateAbbr – GetRecord > Key_Abbreviation
-
Add the following design blocks for error handling:
Design block name Location/Parameters Connections Jump To Error
Context menu > Jump To > Error Automation link: ImportDelimitedFile > Result > False – Jump To Error
Data link: ImportDelimitedFile > message – Jump To Error > errMessage
Jump To Error
Context menu > Jump To > Error
Parameter value: errMessage = Failed to get data from the lookup table
Automation link: GetRecord > Result > False – Jump To Error
- Validate the design blocks and connections with the following figure:
- On the toolbar, click to save the automation.
This Challenge is to practice what you learned in the following Module:
Available in the following mission:
Want to help us improve this content?