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
VPVP 

Problem updating standard pricebook thru API

Using 6.0 API, I am trying to create lineitems for an opportunity that has a standard pricebook associated with it. Through API, I create a Product2 entry for that lineitem product (if required) and then create a PricebookEntry for that with following values:

Pricebook2Id = standard pricebook id (associated with that opp)
Product2Id = id of the Product2 entry created
unit price = specified by me
use standard price = true (as per documentation, this has to be set to true if the pricebook entry is for a std pricebook).

But the create call returns the error "Error 0: Message=No standard price defined for this product". I do not see any other way to define the standard price for that product. What could be the issue here? Or is it that the standard pricebook entries cannot be created through API?
VPVP
Was able to resolve the problem - it seems that before creating opportunity lineitems for a new product using API, a standard pricebook entry also needs to be created for that product, even when current pricebook associated with that opportunity is a custom pricebook. Why is this - I mean in this case why is it not allowed to create just a custom pricebook entry for that product with the UseStandardPrice set to false (without anything in the std pricebook)?