Manipulating application data
To ensure that customers are billed for only the services provided, the program manager wants the application to display a list of the services performed by the service provider. The list must include the following information:
- Name of the service performed
- Unit cost of the service
- Number of times the service was performed
- Total cost for each service
- Total cost of the services performed
On the Perform service flow, configure the CopySelectedServices data transform to copy services provided from a Service case to an Assistance Request case.
Note: For the purposes of this challenge, the Service case type contains one stage. For simplicity, the case does not have a Create stage.
The following diagram displays the relationships of the Selected Services embedded data type in the Assistance Request case type, and the Services data relationship in the Service case type to the Services offered data type.
The following table provides the credentials you need to complete the challenge.
|Application Developer||[email protected]||pega123!|
Note: Your practice environment may support the completion of multiple challenges. As a result, the configuration shown in the challenge walkthrough may not match your environment exactly.
1 Configure the Review service summary step
- In the Pega instance for the challenge, enter the following credentials:
- In the User name field, enter [email protected].
- In the Password field, enter pega123!.
- In the navigation pane of App Studio, click Case types > Assistance Request to open the Assistance request case type.
- In the Assistance request case type, on the Workflow tab, click Review service summary to open the step properties pane.
- In the step properties pane to the right, click Configure view to display a dialog box.
- In the dialog box, click Add field to configure a new field.
- Create a multi-record data relationship named Selected services. In the Type list, select Embedded data. In the Data object list, select Services offered. Click the List of records radio button to designate it as a multi-record data relationship.
- Click Submit & add another to configure a new field.
- Create a currency calculated field named Invoiced total. In the Type list, select Currency.
- Expand the Advanced section and then select the This is a calculated field (read-only) check box.
- In the Calculation section, in the Function dropdown, select Sum of. In the Field dropdown, select Line total.
- Click Submit.
- In the Options for the Description, Quantity, Service, and Unit Cost fields, select Read-only.
- Click Submit to record the new fields and return to the Workflow tab of the case life cycle.
- Click Save to save your changes in the case life cycle.
2 Configure the CopySelectedServices data transform
- In the navigation pane of App Studio, click Case types > Service to open the Service case type.
- In the Perform service process, click Configure Process.
- Click Open process in Dev Studio to open the Perform service flow rule in the flow canvas.
Tip: Alternatively, in Dev Studio, in the App Explorer, expand Service > Process > Flow, and then select PerformService to open the Perform service flow rule.
- On the flow canvas, right-click the Select services connector, and then select View Properties to display the Connector properties dialog box.
- In the Connector properties dialog box, in the Set properties area, select Apply data transform to add a data transform to the connector.
- In the Data transform field, enter CopySelectedServices to name the data transform.
- To the right of the Data transform field, click the Open icon to open the Create Data Transform tab.
- On the Create Data Transform tab, click Create and open to display a new data transform record.
- On the Definition tab of the data transform record, configure the CopySelectedServices data transform.
- On the data transform record, in the Action list, select For Each Page In to repeat over the items in a list. A second, indented row labeled 1.1 is displayed on the record.
- In the row labeled 1, in the Target field, enter or select .Services to repeat over the items in the Services list.
- In the Source column, select the Also use each page as source context check box to use the Services page as the source context to resolve property references.
- In the row labeled 1.1, in the Actions list, select When to configure the condition for selecting a row. A third, indented row labeled 1.1.1 is displayed on the record.
- In the row labeled 1.1, in the Target field, enter .Quantity>0 to only select rows with a quantity greater than zero.
- In the row labeled 1.1.1, from the Actions list, select Append to to append the contents of the selected row to a different list.
- In the row labeled 1.1.1, in the Target field, enter pyWorkCover.SelectedServices to copy the contents of the selected row to the Selected Services data relationship in the Assistance request parent case.
- In the row labeled 1.1.1, from the Relation list, select current source page to copy the contents of the selected row in the Services data relationship in the Service case.
- On the data transform record, click the Pages & Classes tab to define the pyWorkCover page so that the data transform can resolve the Selected services property reference.
- In the Page name field, enter pyWorkCover as the name of the page to define.
- In the Class field, enter or select GoGo-GoGoRoad-Work-AssistanceRequest to define the context of the pyWorkCover page as the Assistance Request case type class.
- Click Save to complete the configuration of the data transform.
- Click the PerformService tab to return to the Perform service flow record.
- In the Connector properties dialog box, click Submit to complete the configuration of the Select services connector that runs the CopySelectedServices data transform.
- Click Save to complete the configuration of the Perform service flow record.
3 Set default property values for service quantity
- From the App Explorer, expand Service > Data Model > Data Transform, and then click pyDefault to open the pyDefault data transform.
Note: If you do not see pyDefault, refresh the App Explorer by clicking Options > Refresh App Explorer.
- In the Pages & Classes tab, enter pyWorkCover for the Page name field and GoGo-GoGoRoad-Work-AssistanceRequest for the Class field.
- In the Definition tab, click Add a row.
- In the Action field, select For Each Page In.
- In the Target field, enter or select .Services.
- Check the box Also use each page as source context.
- In the child step's Action field, select Set.
- In the Target field, enter or select .Quantity.
- In the Source field, enter 0.
- Click Save to save your changes to the new version of pyDefault.
Confirm your work
- Click Create > New > Assistance Request.
- In the Enter customer information form, select [email protected] as the Account ID.
- Advance the case to the Select services view and confirm the default values in each field in the Quantity row is 0.
- Enter the quantities provided in the following image and verify that the total cost is $210.00.
- Click Submit to complete the Select services assignment and resolve the Service case. The Review service summary view is displayed.
- On the Review service summary view, verify that the Selected services table displays the three rows filled out in the Service case and that the value of the Invoice total field is $210.00.
Note: In a real-life implementation, ensure that the list of selected services in the Assistance Request case is read-only and restricts users from adding or removing items. You can remove the Add item and Delete controls by editing the section rule that displays the list, which is outside the scope of this challenge.
Note: The empty first row in the table is a result of the Selected services list initialization. You can remove the empty first row by deleting the .SelectedServices(1).pyLabel created by default in the pySetFieldDefaults data transform, which is outside the scope of this challenge.