Integrating an external data source
7 Tasks
25 mins
Scenario
A REST service has been created to access contact data for a customer. Your task is to access that data to replace the sample data.
Use the following credentials to log in to the exercise system:
Role | User name | Password |
---|---|---|
Application Administrator | cdmadmin | rules |
Your assignment consists of the following tasks:
Task 1: Configure a REST Connector for the external data
Run the REST integration wizard to connect to the external data source.
Task 2: Save the Data Page to your application Ruleset
Create a copy of the Contact Data Page in your application Ruleset.
Task 3: Save the response Data Transform to your application Ruleset
Create a version of the Response Data Transform in your application ruleset.
Task 4: Save the request Data Transform to your application Ruleset
Create a version of the Request Data Transform in your application Ruleset and modify the Applies to field to reference the REST service for the external data.
Task 5: Update the Data Page to reference the external source
Modify the D_Contact page in your application Ruleset to reference the external REST source.
Task 6: Update the data transform to map the response data
Modify the Response Data Transform to map data from the external source to your application.
Task 7: View the external data
Call the REST service and process the response.
Challenge Walkthrough
Detailed Tasks
1 Configure a REST Connector for the external data
Run the REST integration wizard to connect to the external data source.
- On the exercise system landing page, click Launch Pega Infinity™ , and then log in as an Administrator by entering the following credentials:
- In the User name field, enter cdmadmin.
- In the Password field, enter rules.
- In the header of Dev Studio, click Configure > Integration > Connectors > Create REST Integration to run the New REST Integration wizard.
- In the System details section, enter the following connection details:
- In the Name field, enter ExternalCon.
- In the Endpoint URL field, enter http://localhost:8080/prweb/PRRestService/test/01-01-01/getContactData/ContactId/.
- In the Resource path section, select ContactId.
- In the Authentication section, click Add authentication to configure the authentication service:
- Select Define New.
- In the User name field, enter serviceuser.
- Click Set password, and then enter password123!.
- Click Submit.
- Click Next to configure the resource methods.
- In the Resource Name field, enter ExternalCon, and then click Next to configure the Data Model. This is the identifier you use to identify the REST resource in the Contact Data Page.
- On the Data Model page, click Add a REST response.
- In the Add a REST response dialog box, click Run to query the service and get a JSON response.
- Click Submit to save the Data Model.
- Click Next to review the configuration.
- In the Data Layer section, select Skip (I'll do it later), and then click Create to create the REST connector.
You do not need a new data layer, as you integrate the REST Connector with an existing data layer. - Wait for the generation to complete, and then click Close.
2 Save the Data Page to your application Ruleset
Create a copy of the Contact Data Page in your application ruleset.
- In the navigation pane of Dev Studio, click App, and then in the search field, enter Common-LDM-Entity.
- Expand Contact > Data Model > Data Page.
- In the Data Explorer, open the D_Contact Data Page.
- Click Save as, and then on the new page, maintain the default context settings:
Setting
Value
Context
TestApp
Apply to
Common-LDM-Entity-Contact
Add to ruleset
TestApp:01-01-01
- Click Create and open, and then click Save.
3 Save the response Data Transform to your application Ruleset
Create a version of the Request Data Transform in your application Ruleset and modify the Applies to field to reference the REST service for the external data.
- In the App Explorer, expand Contact > Data Model > Data Transform.
- Open the Con_Detail_Response Data Transform.
- Click Save as.
- In the Identifier field, click Edit, and then change the identifier to ExternalCon_Detail_Response.
- On the new page, set the Context settings:
TestApp
Applies to: Common-LDM-Entity-Contact
Ruleset: TestApp:01-01-01
- Click Create and open, and then click Save.
4 Save the request Data Transform to your application Ruleset
Create a version of the Request Data Transform in your application ruleset and modify the Applies to field to reference the REST service for the external data.
- In the navigation pane of Dev Studio, click App, and then in the search field, enter Common-LDM-Entity.
- In the App Explorer, expand Contact > Data Model > Data Transform.
- Open the Con_Detail_Request Data Transform.
- Click Save as.
- In the Identifier field, click Edit, and then change the identifier to ExternalCon_Detail_Request.
- In the Context section, in the Apply to field, enter Common-Admin-Int-External-ExternalConAPI.
- Click Create and open, and then click Save.
- Click the Pages & Classes tab and change the ConnectorPage class to Common-Admin-Int-External-ExternalConAPI
- Complete the Definition tab:
- In row 3, in the Target field, enter connectorPage.request.ContactId.
Use lowercase "d" in "Id" to map to the external data. - In row 4.1, in the Target field, enter connectorPage.request.Contact.ContactID to map the contact ID to the external source.
- Click Save.
- In row 3, in the Target field, enter connectorPage.request.ContactId.
5 Update the data page to reference the external source
Modify the D_Contact Data Page in your application ruleset to reference the external REST source.
- In the App Explorer, open the D_Contact Data Page.
This Data Page is the version saved to the TestApp:01-01-01 Ruleset. - In the Data Sources section, under Profile_Con_Detail, enter the external data source information:
- In the Source list, select Connector.
- In the Type list select REST.
- In the Name field, enter ExternalCon. This is the ConnectorName that calls the Data Transforms using the naming convention: ConnectorName_Method_Request and ConnectorName_Method_Response.
- In the Endpoint URL field, enter http://localhost:8080/prweb/PRRestService/test/01-01-01/getContactData/ContactId.
- In the Method list, select GET.
- Click Save to save the D_Contact Data Page.
6 Update the data transform to map the response data
Modify the Response Data Transform to map data from the external source to your application.
- In the navigation pane of Dev Studio, select App, and then in the search field, enter Common-LDM-Entity.
- Expand Contact > Data Model > Data Transform.
- In the App Explorer, open the ExternalCon_Detail_Response Data Transform. If you do not see the Data Transform in the list, scroll to the top of the App Exlporer and from the menu, select Refresh App Explorer.
- Click the Pages & Classes tab, and then change the ConnectorPage class to Common-Admin-Int-External-ExternalConAPI.
Use the API class because it contains the request and response properties. The response property contains the values from the REST service after you call it. - On the Definition tab, modify row 2:
- In the Relation column, select with values from.
- In the Source column, enter connectorPage.response_GET.
- Click Save.
- Click Add a row to map the following Target fields to the Source fields for the following properties to map fields from the external source:
Target
Source
.ContactID
connectorPage.response_GET.ContactId
.FirstName
connectorPage.response_GET.FirstName
.LastName
connectorPage.response_GET.LastName
.PrimaryAddress.Line1
connectorPage.response_GET.AddressLine1
.PrimaryAddress.Line2
connectorPage.response_GET.AddressLine2
.City
connectorPage.response_Get.City
.State
connectorPage.response_GET.State
.PrimaryAddress.PostalCodeID
connectorPage.response_GET.Zip
- To add a page for the Phone List, click Add a row and configure the following:
- In the Action list, select Append and map to.
- In the Target field, enter .PhoneList.
- In the Relation list, select a new page.
- In the second-level row, in the Target field, enter connectorPage.response_GET.MobilePhone.
- Right-click the second level row, and then select Add sibling below.
- Configure a set action where .IsPrimary is equal to "true".
- To add a page for the Email List, click Add a row and configure the following:
- In the Action list, select Append and map to.
- In the Target field, enter .EmailList.
- In the Relation field, select a new page.
- In the second-level row, in the Target field, enter connectorPage.response_GET.Email.
- Right-click the second level row, and then select Add sibling below.
- Configure a set action where .IsPrimary is equal to "true".
- Click Save to save your changes to the ExternalCon_Detail_Response Data Page.
7 View external data
Now that all the pieces are in place, it is time to call the REST service and process the response.
- Open the D_Contact Data Page, then click Actions > Run.
- In the Run Data dialog box, in the ContactID field, enter ContactId, and then click Run.
The dialog box shows the properties for the Pat Smith contact. - Work around a display error in the Data Portal by refreshing the cache:
- Open the D_Contact Data Page, and then click the Parameters tab.
- Select the Is this page used for alternate key storage? checkbox.
- In the ContactID parameter, in the Linked field, enter ContactId.
- Click Save to save the Data Page.
- In the navigation pane, click Case Types > Contact.
- Click the Settings tab, and then click Default data sources.
- In the Default record lookup data page list, select None.
- Click Save.
- Click Default data sources.
- In the Default record lookup data page list, select Contact.
- In the Profile list, select Constant, and then enter CONTACT_DETAIL.
- Click Save.
- In the header of Dev Studio, click Launch Portal > Data Portal.
- In the navigation pane, click Contacts, then select any contact in the list.
The contact details now show the data from the external source.
This Challenge is to practice what you learned in the following Module:
Available in the following mission:
Want to help us improve this content?