Loading

Import Order Products (OrderItems) into Salesforce Orders Using Data Loader

Date de publication: Jul 6, 2026
Description

This article explains how to use Salesforce Data Loader to insert, update, or upsert Order Products (also called OrderItems) into existing Salesforce Orders. Order Products represent the individual products added to an Order and are stored in the OrderItem object in Salesforce. If you only need to add a small number of products, adding them manually through the Salesforce user interface may be simpler.

Résolution

Understanding the Order Product Data Model

Before importing Order Products using Data Loader, it helps to understand the relationship between the key objects involved:

  • PricebookEntry represents the association between a Price Book and a Product (Product2) in Salesforce.
  • Orders are assigned a specific Price Book when created.
  • OrderItems (Order Products) are linked to Products through PricebookEntry records in the Price Book assigned to the Order.
  • You can only add Order Products via PricebookEntry records that belong to the same Price Book assigned to the Order.
  • You cannot add Products to an activated Order. If the Order is already activated and you try to add or modify products, Salesforce displays this error: "unable to modify activated order: cannot delete order, or add or remove order products". To resolve this, change the Order Status field from "Activated" back to "Draft" using Data Loader before attempting to add products.

Required CSV Fields for Your Import File

Prepare a CSV file with the following columns before running Data Loader:

  • ID — Optional for update or upsert. Include the existing OrderItem record IDs if you are updating existing line items. For upsert, if an ID is not set for a row, Data Loader creates a new Order Product for that row.
  • ORDERID — The record ID of the Order you are adding products to. If adding multiple products to the same Order, create one row per unique product. Export a list of Order IDs from Data Loader by selecting the Order object and using a query such as: SELECT Id, OrderNumber, AccountId, Account.Name, Pricebook2Id, Pricebook2.Name FROM Order WHERE Status = 'Draft'. Note: The query above filters for Draft Orders only, since activated Orders cannot have products added or modified.
  • PRICEBOOKENTRYID — The record ID of the product's Price Book Entry in the Price Book assigned to the Order. Export PricebookEntry IDs using: SELECT Name, Id, UnitPrice, Pricebook2.Name, Product2.Name FROM PricebookEntry WHERE IsActive = true
  • QUANTITY — Required. The number of units for this Order Product.
  • UNITPRICE — Required. The unit price for the Order Product.
  • SERVICEDATE — The start date for the Order Product line item. Refer to Salesforce Data Loader documentation for accepted date format values.

You may need additional fields depending on your org's validation rules or required custom fields on the OrderItem object.

Step-by-Step: Prepare the CSV File

  1. Populate Order IDs for the Orders you want to add products to in the ORDERID column.
  2. Add the corresponding PricebookEntry IDs and Unit Price values.
  3. Enter the Quantity for each line item.
  4. Enter Service Dates for the appropriate line items as required by your business logic.
  5. For upsert: optionally include the existing OrderItem record IDs in the ID column.
  6. For upsert: if you are not making changes to existing line items, remove them from the CSV to avoid Data Loader errors.

Step-by-Step: Run the Import in Data Loader

  1. Open Data Loader and select Insert (to create new) or Upsert (to create new and update existing Order Products).
  2. Check the box for Show all Salesforce objects.
  3. Select Order Product (OrderItem) from the object list.
  4. Choose your prepared CSV file and click Next.
  5. For Upsert: in step 2a, map the ID column from your CSV as the matching field.
  6. Click Next, then create a field mapping by selecting Auto-Match Fields to Columns and click OK.
  7. Click Next, then click Browse to select the directory where success and error files should be saved. Click Finish.
  8. When prompted to confirm, click Yes to begin the import.
Numéro d’article de la base de connaissances

000384893

 
Chargement
Salesforce Help | Article