Back to Salesforce in Google Sheets
SheetXAI logo
Salesforce logo
Salesforce · Google Sheets Guide

Add Products to Salesforce Opportunities in Bulk From a Google Sheet

2026-05-15
5 min read

The Scenario

A sales operations analyst is staring at a Google Sheet with 40 rows. Each row maps an opportunity ID to a pricebook entry ID, a quantity, and a unit price. These are the product line items for a batch of deals that closed during the quarter — deals that were created in Salesforce but had their products tracked in a separate quoting tool.

End of quarter closes in three days. Revenue recognition requires that every closed opportunity have its line items in Salesforce. The analyst needs every row in this sheet to become an OpportunityLineItem record linked to the right opportunity.

The bad version:

  • Open Salesforce, navigate to the first opportunity, find the Products section, click Add Products, search for the pricebook entry by name (you have an ID, not a name), find the match, enter the quantity, enter the price, save.
  • Go back. Find the next opportunity. Add its products. Repeat 39 more times.
  • Halfway through, realize three opportunities share the same pricebook entry ID but with different quantities, and you cannot tell from the UI which entry you added was the right one.
  • Finish an hour later and discover that four opportunities had their pricebooks set incorrectly — the line item add fails if the opportunity is not already linked to the right pricebook.

The quoting data is correct. The opportunities are in Salesforce. The gap between them is 40 rounds of CRM navigation that add nothing except fatigue.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads your quoting rows and creates Salesforce OpportunityLineItem records for each one, writing the result back so you know what landed.

For each row in my sheet with opportunity_id (column A), pricebook_entry_id (column B), quantity (column C), and unit_price (column D), add a product line item to the Salesforce opportunity and write the result to column E.

What You Get

  • A Salesforce OpportunityLineItem record created for every row in your sheet.
  • Each line item linked to the correct opportunity, referencing the specified pricebook entry at the given quantity and unit price.
  • Column E populated with the returned line item ID for each success, or the specific error for any failure — pricebook mismatch, invalid entry ID, opportunity not editable.
  • All 40 rows processed. A failure on one row does not block the rest.

What If the Data Is Not Quite Ready

Some opportunities are not linked to a pricebook yet

Adding a product to an opportunity that has no pricebook set fails. You need to set the pricebook first for those opportunities.

For each row in my sheet: first check if the Salesforce opportunity in column A has a pricebook set. If not, set the pricebook to Standard Price Book. Then add the product line item using pricebook_entry_id from column B, quantity from column C, and unit_price from column D. Write the result to column E.

Unit price in the sheet is in a different currency than the opportunity

Some opportunities are set to EUR, but the sheet has prices in USD. You need currency conversion before writing.

For each row in my sheet, check the currency of the Salesforce opportunity in column A. If the opportunity currency is EUR and the unit_price in column D is in USD, convert the price using the current USD to EUR rate before adding the line item. Write the converted price and the result to columns E and F.

You need to add multiple line items per opportunity

Several opportunities have two or three products. They are listed as separate rows in the sheet with the same opportunity ID.

For each opportunity ID in column A of my sheet, add all rows with that ID as product line items to the Salesforce opportunity — using pricebook_entry_id from column B, quantity from column C, and unit_price from column D. Write the line item ID to column E for each row.

Validate pricebook entries, add line items, flag mismatched currencies, and confirm totals

Before adding, confirm each pricebook_entry_id is valid in Salesforce. Add the line items. Flag any rows where a currency mismatch occurred. Then query each opportunity to confirm its total amount updated correctly.

For each row in my sheet: validate that the pricebook_entry_id in column B exists in Salesforce — write invalid entry to column E and skip if not. For valid rows, check opportunity currency matches expected — write currency mismatch to column F if not. Add the line item and write the returned ID to column E. After all rows, re-query each opportunity in column A and write the updated total amount to column G.

One prompt validates, creates, flags, and confirms.

Try It

Get the 7-day free trial of SheetXAI and open your quoting sheet, then ask it to push every line item into the right Salesforce opportunity before close. See also how to bulk update opportunity stages from a sheet, or browse the full Salesforce integration overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more