📢 Attention Salesforce Certified Trailblazers! Maintain your credentials and link your Trailhead and Webassessor accounts by April 19th. Learn more.
close

Integrate External Data

Learning Objectives

After completing this unit, you’ll be able to:
  • Configure an external lookup relationship.
  • Configure an indirect lookup relationship.
  • Customize the display of external data.
  • Enable record feeds for an external object.
  • Show external data in the Salesforce app.

Define Relationships for the External Objects

After you’ve configured an external data source and defined external objects, you can integrate the external data into Salesforce using relationship fields. You can define three types of relationships for external objects.

  • Lookup relationship—Links a child standard, custom, or external object to a parent standard or custom object. You can only use this type of relationship if the external data includes a column that identifies related Salesforce records by their 18-character IDs. If that’s not the case, use one of the following two types of relationships, which are unique to external objects.
  • External lookup relationship—Links a child standard, custom, or external object to a parent external object. The values of the standard External ID field on the parent external object are matched against the values of the external lookup relationship field. For a child external object, the values of the external lookup relationship field come from the specified External Column Name.
  • Indirect lookup relationship—Links a child external object to a parent standard or custom object. You select a custom unique, external ID field on the parent object to match against the child’s indirect lookup relationship field, whose values are determined by the specified External Column Name.

This table summarizes the different types of external object relationships.

Type of Relationship Child Object Parent Object Must External Data Contain Salesforce IDs?
Lookup Standard, Custom, or External Standard or Custom Yes
External Lookup Standard, Custom, or External External No
Indirect Lookup External Standard or Custom No

As an example, let’s see how you can configure lookup relationships to link orders to their line items and to accounts in your Salesforce org.

Configure an External Lookup Relationship

In the previous unit, you were able to view external order data in your Salesforce org. Recall that when you selected the Orders table for syncing, you also selected the OrderDetails table, which contains line items for each order. By creating an external lookup relationship from OrderDetails to Orders, you can see the line items on an order’s page in your org. In effect, you’re telling Salesforce that a field on one object (OrderId on OrderDetails) corresponds to the external ID field on an external object (Orders).

  1. Log in to your Salesforce Developer Edition.
  2. From Setup, enter External Objects in the Quick Find box, then select External Objects.
  3. Click the OrderDetails external object.Order details screen
  4. Click the Edit link next to Order ID.Edit Order ID
  5. Click the Change Field Type button.Edit Order ID details
  6. Select External Lookup Relationship and click Next. An external lookup relationship can link any object to an external object.
  7. Select Orders as the related object and click Next.Choose related external object
  8. Enter 18 as the length and click Next.
  9. To make the relationship visible to all profiles, select the Visible option and click Next. Specify FLS for external lookup relationshipIn a real production deployment, you would carefully analyze which profiles should have access to order line items.
  10. Click Save to accept the defaults—you definitely want an OrderDetails related list on the Orders page layout!
  11. Use the app menu (top left) to launch Orders.
  12. Click the External ID of an order in the Recent Orders list.View External ID of order
  13. Confirm that you see a list of line items for the order.View line items for order

You can click a line item’s External ID to view its details, but let's show line item details right here on the related list.

  1. In Setup, use the Quick Find box to go to the Object Manager.
  2. Click the Order object, then click Page Layouts | Order Layout.
  3. In the Order Layout box, click Related Lists.Edit layout for order details
  4. Scroll down to the OrderDetails related list, and click the wrench icon.Edit layout for order details
  5. Remove Display URL from the Selected Fields, add product, quantity, and unitPrice, and click OK.Related list properties dialog
  6. Click Quick Save at the top of the page. Now you see order line item details in the related list.

Configure an Indirect Lookup Relationship

Now that you can see the line items on the order page, the next step is to configure an indirect lookup relationship between orders and accounts. This relationship enables your users to see which account a given order is associated with and all the orders for a given account.

An indirect lookup relationship models a foreign key relationship between an external object and a custom or standard object. This time you’re telling Salesforce that a field on an external object (customerId on Orders) corresponds to a unique, external ID field on a custom or standard object (Customer_ID__c on Account). It’s an indirect lookup because it references a field other than the standard ID field.

  1. In Setup, use the Quick Find box to go to the Object Manager.
  2. Click the Order object, then click Fields and Relationships.
  3. Click Edit next to Customer ID.Edit customer ID screen
  4. Click the Change Field Type button.
  5. Select Indirect Lookup Relationship and click Next. An indirect lookup relationship links an external object, such as orders, to a standard object, such as account, or even a custom object.
  6. Select Account as the related object and click Next.Select account
  7. Select Customer_ID__c as the value of Target Field and click Next.Select customer ID
  8. Enter 18 as the length and click Next.
  9. To make the relationship visible to all profiles, select the Visible option and click Next.
  10. Click Save to accept the defaults—you want the Orders related list on the Account page layout!
  11. If the app menu (top right) is not already showing External Orders, click the app menu and select it.
  12. Click the Orders tab.
  13. Click the External ID of an order in the Recent Orders list.
  14. Confirm that the order shows a link in the customerID field.
  15. Click the customerID link. You’re taken to the corresponding account page. Scroll to the bottom to see a list of orders.Orders related list
  16. Again, you can customize the UI to show more useful information in the related list. Select the Quick Access Menu by clicking the gray triangle on the right of the page.
  17. Select Edit Layout.
  18. Scroll down to the Orders related list, and click the wrench icon.
  19. Remove Display URL from the Selected Fields, add orderDate and shippedDate. For Sort By, click orderDate and select Descending so that you see the most recent orders first. Click OK.Orders related list properties
  20. Click Save at the top of the page, scroll down, and see the order dates in the related list.Account with edited list

Now your external order data is integrated seamlessly with accounts.

Enable Chatter for External Data

To integrate the external data further into your Salesforce org, let’s see how to enable Chatter feeds on order records. In the current release, field tracking is not available for external objects; that is, we cannot configure Salesforce to post to a record's Chatter feed as its field values change, but we can still enable the Chatter feed.

  1. Log in to your Salesforce Developer Edition.
  2. From Setup, enter Feed Tracking in the Quick Find box, then select Feed Tracking.
  3. Select Orders (note the plural; the singular Order is a standard object), click Enable Feed Tracking and click Save.Enable Feed Tracking checkbox
  4. Use the App Launcher to go to the Orders app.
  5. Click the External ID of an order in the Recent Orders list.
  6. Now the order has a Follow button that users can click to subscribe to its Chatter feed.Record feed on an external object detail page

View External Data in the Salesforce App

When your external data is available in your Salesforce org, you can view it in the Salesforce app.

  1. Start the Salesforce app. You can run the app on your mobile device (get the app) or in the Salesforce Mobile Simulator Chrome App. Log in with your Developer Edition username and password, if necessary.
  2. Tap Salesforce App Nav to open the navigation menu. Accounts and Orders appear at the top of the Recent list. If they’re not at the top, tap More to show all the objects in the Recent list.Navigation menu
  3. Tap Orders to see a list of recent orders. In addition to the external object that you have configured, a standard object with the same name, Orders, is listed. If you tap Orders and see no recent records, look for the other Orders object.Recent orders
  4. The order you were viewing in the previous step appears at top of the list. Tap it to view its details.Order details
  5. Tap Feed to view the order record’s feed and your feed post.Record feed
  6. Tap Related, then tap OrderDetails to see the order’s line items.Related order line items
  7. Tap Salesforce app's back arrow twice, then tap Salesforce App Nav. Tap Accounts to see a list of recent accounts.
  8. Tap the top account in the list, then tap Related. Scroll down the related lists, then tap Orders to see the orders for that account.Orders related to the account

As you can see, your external data is available in the Salesforce app just as it is in the full Salesforce site, with zero extra configuration!

retargeting