function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Exactdeveloper23 GuptaExactdeveloper23 Gupta 

External Object - error - verify the primary key values

Guys, am trying to set up an external object and when i create a view to load the records for the external object, I get an error: 

The external object record for external data source “oDataTest1” can’t be created. Verify the primary key values.

oDataTest1 is my service
My external table has fields like
JobId, TotalOpens, TotalClicks, TotalSent
External table has JobID as the primary key.

I let SF auto generate the external object for this table.
So External Object now has custom fields like JobID, TotalOpens, totalClicks, totalSent
It also has standard fields like ExternalID and DisplayURL.

The query SF tries to make is:
https://www.exacttargetapis.com/odata/v1/service/Tracking_JobAggregate1?$top=201&$filter=JobID ge 1&$orderby=JobID&$count=true&$select=JobID,TotalClicks,TotalOpens,TotalSent

I confirmed that this service will return the correct records.
But looks like SF is failing on loading the results into the external object?
I verified that my external table does not have duplicate values in primary key field JobID ( it is really a primary key)

Any ideas why I still get this error?
The external object record for external data source “oDataTest1” can’t be created. Verify the primary key values
Agustina GarciaAgustina Garcia
I think that Salesforce is expecting to have a field call "ExternalId" as primary key. So, did you try to change the name? or map the JobId field to ExternalId one?

User-added image

I think this should help, but let me know if not and we can think something else.
Edward Austin 11Edward Austin 11
I'd say it's because the view you created won't have a primary key. Salesforce requires a primary key for external objects.

Depending on the provider you are using for the odata connection you maybe able to hack the metadata to create a primary key there.
hitesh Patel 93hitesh Patel 93
I am using OData in Salesforce Connect to link Oracle View xyz to SF. Successfully fetched the metadata in Salesforce for xyz Oracle view via sync. Then created TAB for XYZ (external table). I was using the tab XYZ to dislay the data  but get error message in Salesforcec "The external object record for external data source “Odata_Oracle” can’t be created. Verify the primary key values" 

I can't create any primary key for any oracle view.  SO, the above statement "maybe able to the hack the metadata  to create a primary key" s in Salesforce do you know what exactly I need to do please 
Juan BlancoJuan Blanco
In case others reach this thread due to the error message, beware that your issue may have nothing to do with what the error message says and, instead, be because of this (at the time of writing, an unsolved 3-year-old Known Issue on Salesforce): https://trailblazer.salesforce.com/issues_view?id=a1p3A000001SGUsQAO