I'm trying to upser a list of Asset records via Database.upsert(List, externalIdField, boolean) and on the externalIdField, I want to pass the standard field 'SerialNumber'.
List<Database.UpsertResult> upsertAssetResult = Database.upsert(finalAssetList, Asset.SerialNumber, false);
However, an error occurred saying an External Id custom field OR a Standard Indexed field must be used.
Invalid field for upsert, must be an External Id custom or standard indexed field: SerialNumber
Now if you go to the Asset standard object, you will see that SerialNumber is an INDEXED standard field and if we believe the error message, it can be used.
Am I missing something? OR is the error message is incorrect and that only External Id custom fields are allowed?
Thanks.
Best Answer
The error message is phrased confusingly. It means there's three qualities that must be met for the field to be used:
This doesn't really express much more than that it has to be an External Id.
For clearer discussion, see Upserting Records and the Upsert SOAP call. The nomenclature there is explained as
(More on idLookup).
Unfortunately, you cannot upsert using any indexed standard field.