Print this page

Import Order Items to my Orders using Data Loader

Knowledge Article Number 000199451
Description I would like to import our customers' Orders and Order Items into Salesforce.

Some of our orders include more than 1 items. I understand that I need to import Orders first using Dataloader and then export Orders IDs from Dataloader in order to import the Order Products (OrderItem) for the particular Orders.

I have been successful in Importing Orders however I am having the hardest time figuring out how to Import Order Products and determine what Fields are necessary for this import.  

I was also told I need the PricebookentryID from Pricebook Entry Object; however I am having a hard time finding that ID declaratively.  I have also tried to pull PricebookentryID from a Product or Pricebook report.

All that being said, how do I setup my CSV and where do I need to go to acquire the PricebookEntryID?


 
Resolution

Foreword: The steps below are for those customers that have successfully Imported Orders or they need to add Products / Items to their established Orders. 

Please note that, depending on your experience with Data Loader and the amount of Orders you need to update as well as the amount of time spent acquiring and preparing your CSV file for a mass update of your (OrderItem) Order Products, it might be more efficient to update the products to orders manually via the user interface. Also, Order records must have an associated Pricebook to be able to import related Order Items. 

There is currently not a way to gather PricebookEntryIDs via a report so you will need to pull the PricebookEntryIDs from Pricebook Entry Object in Data Loader. Please consider promoting the Idea: Add Product ID & Price Book ID to Reports on the IdeaExchange so that we may see the ability to include this Id in reports with a future release.

Requirements: You will need 4 CSV files open simultaneously (4th is only necessary if you are updating Order Product Line Items)

 

1. The CSV Template attached to this article titled "Order Products Template"

2. Export from your Order Object (You can filter the export to include only the orders that were created on the day of you import if needed)

3. Export from your Pricebook Entry Object.  (Keep in mind that you can not have a PricebookentryIDs on the same order that stem from different "Pricebook2ID"s so you may need to filter out particular Pricebooks).

4. Export Order Product (OrderItem) (Optional only for Updating Order Line Items)


Note: the six columns/fields needed for your Order Product CSV to Import / Upsert are as follows: 
 

1. (ID) This is necessary to have a value if you are updating the quantity of an Item on an Order this ID specifies the product line item.  If you do not put this ID on your CSV Data loader will create a new line for the same product so this will compromise your data integrity by causing redundancies.  Also it is vital that the column remain on the CSV even if it is blank.

2. (ORDERID) this will be the identifier for the Order you wish the products to be placed on.  Note you will need to repeat ORDERID as many times as there are Products on your Order.

3. (PRICEBOOKENTRYID) This specifies which Product and which Pricebook the line item is.  Remember the PricebookentryId has to be from the same Pricebook on one order.

4. (Quantity) This will be the initial or the updated number of products.

5. (UNITPRICE) This is necessary for the Upsert /Import to take place even though you would think this information would be connected to the PricebookentryID.

6. (SERVICEDATE) I was successful at Upserting this information with Future Dates, Today's Date, & Past Dates.  Also in US Format ex: 8/7/2014.

Note: You may need to add additional fields depending on your Orgs. Validation Rules and Required Fields for the Order Item / Order Product Object. You can find information about each fields listed above on the API Docs.


Now that you have your 4 CSV files open on your Desktop.  You should have an understanding of what fields and why those fields are being used.  Finally describing what needs to be done and the tediousness of this process will take quite some time.  What we have found that is if you are doing this for thousands of rows it may take a few hundred rows for you to catch your stride. Also if you need to update under a 50 records it may be faster to do this Declaratively.
 

1. Grab the OrderIds from your Order Export a paste them and repeat them as needed onto "Order Products Template" 

2. Collect the PricebookentryIds & Unit Price from the Pricebook Entry Export and line them up with the correct Order(s).

3. Put in the quantity you wish to have for your line item.

4. Put the Service Dates in with the appropriate Line Items or Orders. (Dependent on your Business Logic this is Org and company specific)

5. (Optional) Copy and Paste the Line Items (ID) into the "Order Products Template".

6. (Optional) Edit the Service Date or Quantity for the established Line Items.  If you do not make changes to the line item you will receive Errors in Data Loader.  Also if you are not making changes to the line item there really is no reason to include them onto your new CSV.
 

Now that you have groomed your CSV you will need to log into Data Loader.
 

1. Select Upsert

2. Check the box for "Show all Salesforce objects"

3. Select "Order Product (OrderItem)"

4. Choose the newly groomed CSV that started out as "Order Products Template" and Next.

5. Hit next again (This is why we have the (ID) / Line Item column on the CSV as it is the default Matching Field for Data Loader Step 2a)

6. Create a Mapping, Auto-Match Fields to Columns, click OK, and click Next.

7. 
 Click the Browse... button to select the directory where the success and error files should be saved, then click "Finish".

8. When a pop appears asking you to proceed, click Yes.

 

See Also:
Data Loader Overview
Orders Overview
Preparing Your Data for Import





Attachments
Name Type Size
Order Products Template.csv
0KB

promote demote