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

Export All Salesforce Cases Including Deleted Records Into a Google Sheet

2026-05-14
5 min read

The Scenario

The regulatory request arrived Tuesday morning. Legal needs a full export of every case ever linked to a specific enterprise account — including any that were deleted in the past 90 days — by end of week. Standard Salesforce reports only show active records. The SOQL queryAll endpoint is the only way to reach the soft-deleted ones.

You've never run a queryAll before. You open the Salesforce developer docs.

The bad version:

  • Try to build the queryAll request in the Salesforce Developer Console, realize you need the correct API version, look it up, write the SOQL, run it, get 200 records back in JSON that you now need to parse.
  • Copy the JSON into a text editor, manually extract the fields you need, paste them into your compliance sheet column by column.
  • Realize you missed the IsDeleted flag column that Legal specifically asked for, go back, re-run, re-paste.

This is supposed to be a data retrieval task. It turned into an afternoon of API exploration because the standard export path doesn't reach the records the audit actually needs.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent inside your Google Sheet. It can run Salesforce queryAll requests — which include soft-deleted records — and write the results directly into your sheet with the fields Legal specified.

Run a Salesforce queryAll SOQL including deleted records to fetch every case for AccountId 001xx000003GYk1 and dump CaseNumber, Subject, Status, and DeletedDate into this sheet

What You Get

  • A queryAll request against Salesforce that includes both active and soft-deleted records for the specified AccountId.
  • CaseNumber, Subject, Status, and DeletedDate written into the sheet row by row.
  • DeletedDate populated only for deleted records; blank for active ones so you can filter them separately.
  • A total row count written after the last row so Legal can confirm the export is complete.

What If the Data Is Not Quite Ready

The export needs an IsDeleted flag column, not just a DeletedDate

Legal wants a clear Y/N column rather than reading date presence as the signal.

Use Salesforce queryAll to retrieve all cases for AccountId 001xx000003GYk1 — write CaseNumber, Subject, Status, DeletedDate, and an IsDeleted column that says Yes for deleted records and No for active ones

The scope is by case origin and date range, not by account

The audit covers email-origin cases from Q1 across all accounts.

Use Salesforce Service Cloud queryAll to retrieve all cases — active and archived — where Origin equals Email and CreatedDate falls in Q1 2026, and write them to my sheet with CaseNumber, Subject, Status, Origin, CreatedDate, and IsDeleted

The export is too large to pull in one query — needs batching

The query returns 2,000+ records and you need them all.

Run a Salesforce queryAll for all cases linked to AccountId 001xx000003GYk1, paginate through all results using queryLocator, and write every record to this sheet with CaseNumber, Subject, Status, and DeletedDate — do not stop at the first page

Full audit export: filter, queryAll, flag, and summarize

You need all records, a clear IsDeleted flag, a count of deleted versus active, and a timestamp for when the export ran.

Run a Salesforce queryAll for all cases under AccountId 001xx000003GYk1, write CaseNumber, Subject, Status, DeletedDate, and IsDeleted into this sheet, add a summary row at the bottom with the count of active cases and deleted cases separately, and write the export timestamp in the cell above the headers

One prompt produces the complete audit package.

Try It

Get the 7-day free trial of SheetXAI and open your compliance sheet, then ask SheetXAI to run the queryAll export. For related reading, see the hub overview or the spoke on bulk-creating cases — which covers the other direction of the same API.

Stop memorizing formulas.
Tell your spreadsheet what to do.

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

Learn more