You need to sign in to do that
Don't have an account?
Stephen Siggs
INVALID_FIELD error upserting to Product2
I am getting the following error trying to Upsert to Product2: INVALID_FIELD: Field name provided, ProductCode does not match an External ID, Salesforce id, or indexed field for Product2.
ProductCode is definitely a field and it is showing as being indexed in the App Setup, Customize, Products area. What am I doing wrong!?
Note: using the SalesForce default sandbox setup - no customisations have been made.
I am sure that this is a daft newbie question, but I've been searching for ages and can't find an answer myself or an example of using upsert for Product2 that answer the question. Thanks in advance!
ProductCode is definitely a field and it is showing as being indexed in the App Setup, Customize, Products area. What am I doing wrong!?
Note: using the SalesForce default sandbox setup - no customisations have been made.
I am sure that this is a daft newbie question, but I've been searching for ages and can't find an answer myself or an example of using upsert for Product2 that answer the question. Thanks in advance!
Upsert can be only used with ID, External ID or field having idLookup = true. ProductCode is not having idLookup = true, neither ID field nor External id hence can not be used for matching.
All Answers
Here is the sample code but without ProductCode.
Product2 p2 = new Product2(Name='Test Product', isActive=true);
insert p2;
Upsert can be only used with ID, External ID or field having idLookup = true. ProductCode is not having idLookup = true, neither ID field nor External id hence can not be used for matching.
The purpose of the code I am writing is to sync the list of Product in SalesForce.com to the list of products that the User has in their ERP system.
Here you should use External Id, which is very handy for storing primary key of external systems like ERP.
Tried creating a custom External Lookup field and now getting an error: INVALID_FIELD: Field name provided, POProductCode__c does not match an External ID, Salesforce id, or indexed field for Product2. field is ticked as being indexed and is visible and editable for all Profiles in field level security.