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
Antonio GiossaAntonio Giossa 

Error trying to insert PriceBookEntry

I am developing a MS Visual Basic .NET application that uses SalesForce objects.

I succesfully created PriceBook and Products objects, but I have a problem when I try to create an element in the PriceBookEntry table.

The steps are:

1) I create SF objects:

        Dim osfPrecios As New PricebookEntry
        Dim errPrecios As New PricebookEntry

        Dim objResultados() As SaveResult

2) I define the data of the new registry:

        osfPrecios.IsActiveSpecified = True
        osfPrecios.IsActive = True
        osfPrecios.Pricebook2Id = parCodigoListaPreciosSF
        osfPrecios.Product2Id = parCodigoProductoSF

        osfPrecios.UseStandardPrice = False
        osfPrecios.UnitPrice = CDbl(parPrecio)

3) I try to create a new registry:

        objResultados = objSF_Service.create(New sforce.sObject() {osfPrecios, errPrecios})

The result: I get an error.

The error is: "UnitPrice field is required"

The data is correct.  I put a valid data in Pricebook2Id and Product2Id fields.

The priceBook I am using is not the default pricebook. It is one created by my application and I can see it in SalesForce.

I saw in the SalesForce documentation ("Standard Object Reference") that UnitPrice is a required field when I am updating non-default pricebooks.

When I debug my VB application, I watch the price variable and it has a correct value. You can see this at:

http://www.creativeitnetwork.com/docs/Error_UnitPrice.gif

But I do not know why I get this error message, since the UnitPrice field shows (before the error) that it has a value.

Yours,

____________
Antonio Giossa
System Engineer
Creative Network Argentina

SuperfellSuperfell
You need to add

osfPrecios.UnitPriceSpecified = true
Antonio GiossaAntonio Giossa
Dear Simon:

Works fine!. Thanks a lot.

Strange... I do not have the "UnitPriceSpecified" property in the PriceBookEntry object documentation at "Standard Object Reference".

Yours.

____________
Antonio Giossa
System Engineer
Creative Network Argentina

SuperfellSuperfell
Its a "feature" of the .NET web services stack, nothing to do with salesforce.com