I'm PHP Client library to push data to Salesforce (https://github.com/developerforce/Force.com-Toolkit-for-PHP)

I'm trying to create a new order, as I understand, I will need to:

  • Create an Order
  • Create OrderItems for that Order

When I tried to create a first OrderItem for the Order, it said that I need to assign a price book for the order I created (what I did before but no succeed).

The error message returned from the server: "Order: bad field names on insert/update call: Pricebook2Id"

Any help would be appreciated!

Code to create a new order:

$data = new stdClass();
$data->AccountId = $accountModel->getSfAccountId();
$data->Pricebook2Id = $standardPricebookId;
// Billing
$data->BillingCity = $billingAddress->getCity();
$data->BillingCountry = $billingAddress->getCountry();
$data->BillingPostalCode = $billingAddress->getPostcode();
$data->BillingState = $billingAddress->getRegion();
$data->BillingStreet = $billingAddress->getStreet();
// Shipping
$data->ShippingCity = $shippingAddress->getCity();
$data->ShippingCountry = $shippingAddress->getCountry();
$data->ShippingPostalCode = $shippingAddress->getPostcode();
$data->ShippingState = $shippingAddress->getRegion();
$data->ShippingStreet = implode("\n", $shippingAddress->getStreet());

$data->EffectiveDate = $order->getCreatedAt();
$data->Status = 'Draft';

$response = $this->salesForceConnection->create(array($data), 'Order');

Code to create a new OrderItem

    $data = new stdClass();
    $data->PricebookEntryId = $pricebookEntryId;
    $data->Quantity = $item->getQty();
    $data->UnitPrice = $item->getPrice();
    $data->Description = $description;
    $data->OrderId = $sfOrderId;

    $this->salesForceConnection->create(array($data), 'OrderItem');
  • 1
    Hi. Could you post your code please? Commented Dec 2, 2015 at 13:02
  • @MartinLezer I updated the post and included code. Thanks! Commented Dec 3, 2015 at 1:21

1 Answer 1


Seems like I know what's going on.

After logging in with SforceEnterpriseClient, the endpoint returned from Force.com server has version 27.0, after replacing 27.0 with 28.0, it worked!

Seems like the PHP Toolkit is already out of date. :(

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .