Skip to main content

Integrating an external data source

6 Tasks

25 mins

Visible to: All users
Beginner Pega Customer Service 8.8 English
Verify the version tags to ensure you are consuming the intended content or, complete the latest version.

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 Admin@TestApp password123!

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 and response data transform to your application ruleset

Create a copy of the Contact data page and the Response Data Transform in your application ruleset.

Task 3: 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 4: Update the data page to reference the external source

Modify the D_Contacts page in your application's ruleset to reference the external REST source.

Task 5: 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 5: View the external data

Now that all the pieces are in place, it is time to call the REST service and process the response.

 

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

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.

  1. Log in as Administrator, with username Admin@TestApp using password password123!
  2. In the header of Dev Studio, click Configure > Integration > Connectors > Create REST Integration to run the New REST Integration wizard.
  3. Enter the following connection details:
  4. In the Name field, enter: ExternalContactData
  5. In the Endpoint URL field, enter: http://localhost:8080/prweb/PRRestService/test/01-01-01/getContactData/{ContactId}
  6. Click Add authentication to configure the authentication service:
    1. Select Define New.
    2. In the User name field, enter: serviceuser
    3. Click Set password, then enter: password123!
    4. Click Submit.
  7. Click Next to configure the Resource methods.
  8. In the Resource Name field, enter GET_ExternalContactData
  9. Click Next to configure the data model.
  10. On the Data model page, click Add a REST response.
  11. In the Add a REST response dialog box, click Run to query the service and get a JSON response.
  12. Click Submit to save the data model.
  13. Click Next to review the configuration.
  14. Click Create to create the REST connector.
  15. Wait for the generation to complete, then click Close.

2 Save the data page and response data transform to your application ruleset

Create a copy of the Contact data page and the Response Data Transform in your application ruleset.

  1. In Dev Studio, in the navigation pane, click Data types.
  2. In the Data Explorer, click Contact to display Contact class.
  3. Click the Sources tab, then click the first Contact page to display the the D_Contacts data page.
  4. Create a copy of the D_Contacts page in your application's ruleset.
    1. Click Save as.
    2. On the new page, maintain the default Context settings:

      TestApp

      Applies to: Common-LDM-Entity

      Ruleset: TestApp:01-01-01

    3. Click Create and open, and then click Save.
  1. Create a copy of the Response Data Transform in your application ruleset.
    1. On the new D_Contacts page, in the Data Source section under Profile_Con_Detail, next to the Response Data Transform field, click the Open icon. The Con_Detail_Up data transform is displayed.
    2. Click Save as.
    3. On the new page, maintain the default Context settings:

      TestApp

      Applies to: Common-LDM-Entity

      Ruleset: TestApp:01-01-01

    4. Click Create and open, and then click Save.

You now have the Contact data page and the Response Data Transform in the TestApp ruleset. You modify these files to reference the external data source.

3 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.

  1. Create a copy of the Request Data Transform in your application's ruleset.
    1. On the new D_Contacts page, in the Data Source section under Profile_Con_Detail, next to the Request Data Transform field, click the Open icon. The Con_Detail_Down data transform is displayed.
    2. Click Save as.
    3. On the new page, use these Context settings:

      TestApp

      Applies to: Common-Int-External-GET_ExternalContactDataAPI

      Ruleset: TestApp:01-01-01

    4. Click Create and open, and then click Save.
  1. Click the Pages & Classes tab and change the ConnectorPage class to: Common-Int-External-GET_ExternalContactDataAPI
  2. On the Definitions tab, to map the contact ID to the external source, set the Target field in step 6 to: connectorPage.request.ContactID
  3. Click Save.

4 Update the data page to reference the external source

Modify the D_Contacts page in your application ruleset to reference the external REST source.

  1. Open the D_Contacts page. This is the version saved to ruleset TestApp:01-01-01.
  2. In the new D_Contacts page, in the Data Source section, under Profile_Con_Detail, enter the external data source information.
    1. In the Source field, change the selection from Aggregate sources to Connector.
    2. In the Type list select REST and in the Name list, select GET_ExternalContactData
  3. In the Request Data Transform field, select Con_Detail_Down. Ensure that you select the version in your application ruleset.
  4. In the Response Data Transform field, select Con_Detail_Up. Ensure that you select the version in your application ruleset.
  5. Set the Endpoint URL to the URL for the external data source: http://localhost:8080/prweb/PRRestService/test/01-01-01/getContactData/{ContactId} and the method to GET.
  6. Click Save to save the D_Contact page.

5 Update the data transform to map the response data

Modify the Response Data Transform to map data from the external source to your application.

  1. On the D_Contacts Data Page, in the Response Data Transform field, click the Open icon to open the Con_Detail_Up transform.
  2. Click the Pages & Classes tab and change the ConnectorPage class to: Common-Int-External-GET_ExternalContactDataAPI

    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.
  3. Click Save to save the changes to D_Contact.

    After saving, the page displays some undefined property errors, which you fix in the following steps.
  4. On the Definitions tab, modify the Source fields for the following properties to map fields from the external source. (The properties are listed in section 5.2.)

    Target

    Source

    .ContactID

    .response_GET.ContactId

    .FirstName

    .response_GET.FirstName

    .LastName

    .response_GET.LastName

    .Name

    response_GET.FullName

    .MaritalStatus

    response_GET.MaritalStatus

    .Salutation

    .response_Get.Salutation

    .MotherMaidenName

    .response_GET.MothersMaidenName

  1. On the Definitions tab, disable or delete undefined properties.

    Properties that are not defined in the external data source result in an error message at the top of the Definitions page. To resolve the errors, right-click on the line number, then select Disable or Delete.
  2. On the Definitions tab, add a page for the Phone List.

    To add a line, right-click an existing line number in the 5.2 section, then select Add sibling below.
  3. Add a line in the 5.2 section (for example 5.2.50), then set Action to Append and map to, set Target to .PhoneList , and set Relation to a new page.
  4. In the second-level line (for example, 5.20.50.1) set .Phonenumber to .response_GET.MobilePhone.
  5. Add another second-level line (for example 5.2.50.2) and set .IsPrimary to "true".
  6. On the Definitions tab, add a page for the Email List.
  7. Add a line in the 5.2 section (for example 5.2.51) and set Action to Append and map to, set Target to .EmailList , and set Relation to a new page.
  8. In the second-level line (for example 5.2.51.1) set .Email as equal to .response_GET.Email.
  9. Add another second-level line (for example 5.2.2.51.2) and set .IsPrimary equal to "true".
  10. Click Save to save your changes to the Con_Details_Up page.

6 View external data

Now that all the pieces are in place, it is time to call the REST service and process the response.

  1. Open the D_Contacts data page, then click Actions > Run.
  2. In the Run Data dialog box, in the ContactID field, enter ContactId, then click Run. The dialog shows the properties for the Pat Smith contact.
  3. To work around a display error in the Data Portal, you must refresh the cache:
    1. Open the D_Contact data page and click the Parameters tab.
    2. Select the Is this page used for alternate key storage? checkbox.
    3. In the ContactID parameter, in the Linked field, enter ContactId.
    4. Click Save to save the data page.
    5. In the navigation pane, click Case types > Contact.
    6. Click the Settings tab, then select Default data sources.
    7. In the Default record lookup data page field, select None.
    8. Click Save.
    9. Click Default data sources.
    10. In the Default record lookup data page field, select Contact.
    11. In the Profile field, select Constant, then add CONTACT_DETAIL
    12. Click Save.
  4. In Dev Studio, click View > Data Portal.
  5. In the navigation pane, click Contacts, then select any contact in the list. The contact details are replaced with the data from the external source.

Congratulations! You have successfully integrated external data from a REST service into a Pega application!



Available in the following mission:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice