1

I have read the documentation about ExternalId field on Product2 standard object

ExternalId  
Type: string
Properties: Create, Filter, Group, Nillable, Sort, Update
Description:  The unique identifier of a record in the linked external data source. For example, ID #123.

And I tried to execute the code

upsert new Product2() ExternalId;

to upsert a new Product record using this external Id field but received the following error:

{
  "column": "1",
  "compileProblem": "Invalid field for upsert, must be an External Id custom or standard indexed field: ExternalId",
  "compiled": "false",
  "exceptionMessage": "",
  "exceptionStackTrace": "",
  "line": "1",
  "success": "false"
}

Also, if I try to make REST API PATCH Request

PATCH /services/data/v59.0/sobjects/Product2/ExternalId/ABC

{"Name":"updated product name", "ExternalId": "ABC"}

I receive an error 404 Not Found, "Provided external ID field does not exist or is not accessible: ExternalId".

enter image description here

Why? How should I resolve this error?

2 Answers 2

1

ExternalId is to be used with ExternalDataSourceId. It is not meant to be a Salesforce External Id, but rather an ID for a record in an external Data Source. The documentation describes the field as:

The unique identifier of a record in the linked external data source. For example, ID #123.

If it were meant to be used as an External ID within Salesforce, the verbiage would be different. Also, I'm not aware of any standard fields called External ID on any standard object. Usually, the Name field serves as an External ID within Salesforce, so having another such field would be redundant.

Also, Standard 'External ID' field on Product says:

The standard field called 'External ID" is not, in Salesforce terminology, an 'External ID' field. It is a Text field, but it is not indexed. You can use an External ID in place of a related record's Salesforce record ID to relate or associate records to each other as you process an upsert operation to Import Related Records with Data Loader.

4
  • Actually, Name field is not unique. What I needed when i implemented some integration, was to add 'ExternalId__c' custom field with External Id and Unique attribute to every standard or custom object that I had to integrate with external systems. I hoped this was done already for Product2, haven't seen this article. So adding ExternalId unique External Id field won't be redundant assuming you need to integrate
    – Patlatus
    Nov 30, 2023 at 8:21
  • @Patlatus I think you've misunderstood. I'm saying that all standard and custom objects, in general (with exceptions) can use the Name field when using the upsert function As long as each value is unique, this works. As such, Since Product2 Name can be used to upsert, it would be redundant to also have an External ID field to upsert against by default. It would also make Product2 unique amongst objects if External ID were an External ID.
    – sfdcfox
    Nov 30, 2023 at 12:14
  • well, the product name may not be unique and the values may differ in different systems, so it is not reliable key for integration. Usually some primary key from external system should be used, which would be strange to put into the Name field, so this is not really an option for integration
    – Patlatus
    Nov 30, 2023 at 12:22
  • @Patlatus I understand what you're saying, but I think you're fixated on the wrong point. What I'm saying is that there are no objects that have a built-in field specifically called ExternalID whose purpose is to be an External ID, since Name is the default External ID field for most objects. Whether or not that behavior is useful for a specific use case is besides the point. Salesforce only has at most one field per object that can be used as an External ID by default, and if there is, it's the Name field.
    – sfdcfox
    Nov 30, 2023 at 14:06
1

It's a trap.

Despite being called External Id, this field lacks External Id property.

If we fetch describe result /services/data/v59.0/sobjects/Product2/describe, we explore and find that externalId: false on this field

enter image description here

Also it is not indexed.

enter image description here

So a custom ExternalId__c field with External Id property turned on should be created instead.

I also have opened a SF Support case to report this bug, let's see what they will respond.

Update: the response from SF was to open an idea on ideaexchange. So I have opened one, please vote who agrees this is misleading https://ideas.salesforce.com/s/idea/a0B8W00000QLPBjUAP/fix-discrepancy-in-external-id-fields

1
  • It's not a trap, just a questionably labeled field.
    – sfdcfox
    Nov 29, 2023 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .