SFDC Connect / External Objects

Want to view your backed-up data as a native Salesforce Related List or via Salesforce Reports and Salesforce native Search?

Introduction

Want to view your backed-up data as a native Salesforce Related List or via Salesforce Reports and Salesforce native Search? Let's take a look at utilizing Salesforce Connect / OData to set up GRAX External Data Sources.

🚧

If you are interested in implementing GRAX with Salesforce Connect, we recommend reaching out to GRAX Support to review environment-specific considerations. Given various Salesforce-imposed limits, along with general considerations for external objects, there are some pieces not under GRAX control and thus should be carefully reviewed.

Creating a Salesforce External Data Source

🚧

Salesforce Connect

Note you will need Salesforce Connect in order to leverage external objects and the functionality described here.

  1. Create a new external data source to connect to the GRAX OData provider:
  2. Go to your Salesforce environment
    a. Go to setup and search for "External Data Sources" (Odata connector)
    b. Create a new External Data Source
    c. Credentials should be as follows:

Credential Name

Value

External Data Source

grax-odata

Type

Salesforce Connect: Odata 4.0

URL

https://<<your grax domain>>/grax.svc

Use Free-Text Search Expressions

☑️

Identity Type

Named Principal

Authentication Protocol

Password Authentication

Username

From the GRAX Configuration - GRAX API tokens Gateway Token

Password

From the GRAX Configuration - GRAX API tokens API Token

d. Click Validate and Sync
e. Click the checkbox next to the objects you want to sync and then click sync
f. Click on the external object that you just created (click the option for Allow Reports)
g. As necessary, go to the fields which you want to display/use in your report and confirm that the field level security is set for each field as desired

Creating Standard Salesforce Reports Using External Objects

🚧

Important Note

With External Objects Salesforce limits you to display 2,000 rows per external object. To be able to view more than 2,000 rows you will need to utilize a reporting tool such as Einstein Analytics. Salesforce limits may change so please refer to Salesforce documentation for current limits.

  1. It is important to first verify that this External Object can be reported on.
  2. Click on your username, and then click on Setup --> Develop --> External Objects
  3. Click on the name of the “External Object” which you want to report on.
  4. Ensure that Allow Reports is set to true
  1. Click on the Reports tab
  2. Click new report
  3. Search for the name of your external object, for example “graxcaseindex”, or the name of your external object.
  1. Click the name of your object, and then click Create
  2. Drag and drop fields on to your report as desired.
  3. Important Note: If you do NOT see a field displayed in the report, make sure to go to the External Object, and click on that field name, and ensure that the field-level security has been set for the users Profile.

Related List

In order to view the external object as a related list, you will need to be sure the object has a lookup relationship to the parent. See here for official Salesforce help regarding the different types of lookup relationships for external objects. Once you have the correct lookup relationship, you will be able to drag the object as a related list on the relevant page layout.

In this example below, we are creating a standard lookup field on the external object graxopportunityindex that points to the Account object. In the lookup field details, we specify the External Column Name to be the exact Salesforce API name of the relationship field (this is case-sensitive). You should be able to find this API name on the external object itself. Once you do this you will need to validate and sync the external object again. Then you should be able to drag the related list on the relevant Account page layouts in this example and see related external opportunities.

Example of linking an external object to an existing object in Salesforce.

If you were linking an external object to another external object, you would use an External Lookup, and the External Column Name in Salesforce would need to be the external identifier from GRAX. Every lookup field in GRAX will have an external identifier (org ID + record ID). As you can see in a sample scenario below, if you have a record that has a lookup field to Class__c object, GRAX also has a unique identifier for this lookup field, which has "grax_xf" in the field name.

🚧

External Lookups

Please reach out to GRAX for more information on whether external lookups are supported for your particular setup, as external lookups may not be supported in all GRAX versions.

We recommend also exploring the GRAX Lightning Connect tool which has advantages over Salesforce external objects, such as the ability to filter only specific records in the related list.

Restore External Object Record

After you set up the external object and are able to view GRAX data within Salesforce, you can also set up a Salesforce Button on the object that will allow you to restore the GRAX record back into Salesforce.

Create a Salesforce javascript button on the external object using the below sample code. The following parameters in the code will need to be updated to reflect your particular environment:

externalObjectAPIName
objecttype

{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/42.0/apex.js")}

var params = {
    externalObjectAPIName: "graxcaseindex__x",
    externalObjectId: window.sfdcPage.getEntityId(),
    objecttype: "Case"
};

if(confirm("Click OK to re-create this record")) {
    sforce.apex.execute("grax.GRAXJSWSButtons", "restoreExternalObject", {
        params: JSON.stringify(params)
    }, { 
        onSuccess: function(result) {
            result = JSON.parse(result);
            
            alert(result.state || result.error);
        },
        onFailure: function(error) {
            alert('Error!');

            console.error(error);
        }
    });
}

🚧

Note

Currently external object restore button is only supported in Salesforce Classic, and only restores the record you are viewing (not children). To view full restore functionality, please refer to the GRAX Restore help.