Print this page

Update Quote Line Item Products via Data Loader

Knowledge Article Number 000233640
Description It's not possible to update existing line item Products via the Data Loader due to complications outlined in the article, Product name in Quote Line Items related list does not match Quote Line Item record's Product.

As a workaround, it's possible to re-insert updated Quote Line Items as new records by exporting existing line items, updating the export file with the new Product's Price Book Entry Ids, inserting the new Quote Line Items associated to the new products, and then deleting the original Quote Line Items.

 
Resolution
Warning
WarningAlways back up your data before performing any data operation. See Exporting Backup Data or Export Data for more details. It is recommended to run a test with a small subset of records to ensure the operation was successful through manually opening and verifying that the corresponding records are correct in Salesforce.

1. Export existing Quote Line Item (QuoteLineItem) records using the Data Loader to Export Data.

- Open the Data Loader and select Export | Login if prompted | Next.

- For Step 2: Select Data Objects, check "Show all Salesforce objects" and select "Quote Line Item (QuoteLineItem)" | Click Browse... and choose a location and file name for your export's resulting csv | Save | Next >

-
 Click the "Select all fields" button and optionally, add any filter conditions to limit your results to the records you'd like to update | Finish | Yes.

2. Rename the ID column in your export file to "OLD ID" and update the existing values in the PRICEBOOKENTRYID column with your desired new Product's corresponding PricebookEntryIds.

Note: A quote must have a price book selected to add Products and you can only add products from a single price book. Changing a selected price book will delete all existing products from the quote.

You can update a Quote's assigned Pricebook using Data Loader via the Quote's Pricebook2Id field but only when the Quote does not have any associated line items. If Products are associated via Quote Line Items you'll encounter the error, INVALID_FIELD_FOR_INSERT_UPDATE: You Cannot Modify The Quote Price Book On Quotes Which Have Quote Line Items upon attempting to update the Quote's Pricebook2Id.

If you do not know your desired product's PricebookEntryIds you can:

A) Manually retrieve PricebookEntryIds via the User Interface by navigating to the Price Book Tab, opening the Pricebook that contains the desired product(s) and also assigned to the Quote for which you're updating Quote Line Items.
 
Clicking the View Action for the corresponding Product in the Price Book page's Products section opens the Price Book Entry record and the page's corresponding URL in your browser will contain the PricebookEntry Id.

For example, from the URL: https://<YourInstanceOrMyDomainHere>.salesforce.com/01ua000000fgBO4 the Pricebook Id is: 01ua000000fgBO4

B) Identify what Price books are assigned to each Quote you intend to update line items for, then use the corresponding Price Book Id(s) to query the PriceBookEntry table to generate a list of Products with their PricebookEntry Ids for reference in updating your export file.

To identify which Pricebook is currently assigned to the Quote and to get it's corresponding Pricebook Id you can either:

- Run the following Query by opening Data Loader and selecting Export | check "Show all Salesforce objects" and select the "Quote (Quote)" object and pasting the following query into the Data Loader's query editor at Step 3: Edit your Query:

SELECT Id, Name, Pricebook2Id FROM Quote


This will generate a csv that lists all of your existing Quotes with their Id, Name, and their assigned Pricebook2Id (Price Book's Id) for reference.

OR

- Navigate to the Quote record in Salesforce. If it has an assigned price book, it will be listed after the title of the Quote Line Items related list in paranthesis.

For example, if you navigate to the Quote Line Item related list on the Quote and it shows, "Quote Line Items (Standard Price Book)" that means that the Quote is assigned the Standard Pricebook. Once you have the name of the Pricebook open it via the Price Books Tab which can be found via the All Tabs view. See Available Salesforce Tabs for more details.


After opening the Pricebook the corresponding URL in your browser will contain the Pricebook's Id.

For example, from the URL: https://<YourInstanceOrMyDomainHere>.salesforce.com/01sa0000000L81b the Pricebook Id is: 01sa0000000L81b.


Once you have the Quote's assigned Pricebook Id you can generate a list of Products contained in the Pricebook to get the new product's corresponding PricebookEntryId for update.
 
C) Create a list of PricebookEntryIds for a particular Pricebook via Data Loader, Select Export | check "Show all Salesforce objects" and select the "Price Book Entry (PriceBookEntry)" and select the following query fields:

Id
Name
Pricebook2Id

Product2Id

Optionally, select any additional fields that may be helpful in identifying the desired Product.

- Add the filter condition: Pricebook2Id equals the Pricebook Id from step B. (the Id of the Pricebook that you'd like to generate a list of products for).

For example, if your Pricebook Id is: 01sa0000000L81b your conditional filter would be: Pricebook2Id equals 01sa0000000L81b.

Click Add Condition and the generated query in the Data Loader's editor should be similar to:

Select Id, Name, Pricebook2Id, Product2Id FROM PricebookEntry WHERE Pricebook2Id = '01sa0000000L81b'

Click the Finish button and Yes when prompted to begin the export.


- The ID column in the resulting export's csv contains the PricebookEntryId(s) which you can use as reference to update your Quote Line Item export file with new Products as mentioned in Step 2.

3. Once you have updated your existing Quote Line Item export file with your new Product's corresponding PricebookEntry Ids and saved it in Excel you're ready to re-insert the Quote Line Items with their updated products.
 
Note: If you wish to maintain the original Quote Line Item's audit field (Created by and Last Modified by) data it is recommended that you enable the feature, "Set Audit Fields upon Record Creation" before proceeding. See Set Audit Fields and Update Records with Inactive Owners for more details.

- Open the Data Loader and choose Insert.

For Step 2: Select Data Objects, check "Show all Salesforce objects" and select "Quote Line Item (QuoteLineItem)" | Click Browse... and select your updated export file containing the new Quote Line Item Products | Open | Next>.

For Step 3: Mapping, click the "Create or Edit a Map" button and then choose the "Auto-Match Fields to Columns" NOTE: You need to unmap the PRODUCT2ID field by clicking and dragging it from the column mapping in the bottom pane up to the top pane. This is necessary to prevent incorrectly associating the old Products for the newly inserted Opportunity Line Items.

Once you have ensured that all fields are mapped except for PRODUCT2ID click Ok | Next >

Click Browse... to select where you would like your Success and Error files to be saved on your local machine | Finish | Yes.

If the Insert was successful your Quote will now contain both the original Quote Line Items and the newly inserted line items with their updated Products.

If the Insert failed review the error messages provided in the Error file, make necessary corrections and attempt the Insert again.

4. Now you'll need to delete the original Quote Line Items since you have now re-created them with your updated Products.

- In Data Loader select Delete.

For Step 2: Select Data Objects, check "Show all Salesforce objects" and select "Quote Line Item (QuoteLineItem)" | Click Browse... and select your export file containing the renamed ID to OLD ID column from Step 2. | Open | Next> | Ok.

For Step 3: Mapping, click the "Create or Edit a Map" button and drag the Id column in the top pane down to match the "OLD ID" file header. Confirm OLD ID is mapped to Id and click OK | Next >

Click Browse... to select where you would like your Success and Error files to be saved on your local machine | Finish | Yes.

If the Delete was successful your Quotes will now only contain the newly inserted line items with your updated Products.

If the Delete failed review the error messages provided in the Error file, make necessary corrections and attempt the delete again.




promote demote