◆ 무한한 가능성/& JAVA

[Salesforce] SOAP API, Unable to create/update fields: Product2Id. Please check the security settings o

치로로 2018. 3. 30. 16:53

ref.> https://success.salesforce.com/answers?id=90630000000gk6GAAQ


SOAP API

PricebookEntry




Robby Williams

Is this an error in the dataloader, or are you doing this via SOAP/JAVA/C#?

I've been using JAVA to write a program to write this, and ran into the exact same error.  If you use the method of DescribeSObject for PRICEBOOKENTRY, you will see that only the following fields are updateable: 
  • UnitPrice
  • IsActive
  • UseStandardPrice
In addition, the following fields are createable: 
  • Pricebook2Id
  • Product2Id
  • UnitPrice
  • IsActive
  • UseStandardPrice
So, to update a PricebookEntry, this is what I did : 

1) Update/Insert Products and store the Source Ids and Target Ids

2) Update/Insert Pricebooks and store the Source Ids and Target Ids

3) Query all pricebook entries from my target org, and store in memory as SObjects (Referred to as TargetObjects)

4) Read all pricebook entries that I want to update from my source file, and store in memory as SObjects (Referred to as SourceObjects)

4a) Sort through your SourceObjects, and replace all of the Source Ids for Products (Product2Id) with the Target Ids returned in step 1

4b) Sort through your SourceObjects, and replace all of the Source Ids for Pricebooks (Pricebook2Id) with the Target Ids returned in step 2

5) Compare the your TargetObjects and SourceObjects, by their Product2Id and Pricebook2Id to find matches

5a) If any match is found, create a new SObject with all of the updateable information from the TargetObject, and the ID of the SourceObject(Referred to as UpdatePBESObjects).

5b) If any are found to not have a match, create a new SObject with all CREATEABLE fields, populated by the SourceObject, and no Id specified.

6) Sort your Createable SObjects from Step 5b, and separate those into two sets : One with the Standard Pricebook's Pricebook2Id (Referred to as StandardPBESObjects), and one set with all other Pricebook2Id(Referred to as PBESObjects).
NOTE : This is important, in that your upsert will fail if there is an entry from ANY other pricebook, but no Standard Pricebook Entry exists.

7) Send the items from your StandardPBESObjects to your org, using the create/insert API

8) Send the items from your PBESObjectsto your org, using the create/insert API

9) Send the items from your UpdatePBESObjectsyour org, using the update API

Hope this helps!

Robby