Skip to main content


Showing posts from April, 2018

Using the CLI and Powershell

Deleting: First, write the list of records to a file (you could just save to a variable but it can come in handy to keep a list of IDs when modifying records)

force query "SELECT Id FROM Object__c WHERE Field__c = 'Whatever'" | Out-File .\ids_to_delete.csv

If it's not a big list, just pipe that back into a CSV object and iterate over it, deleting each one with "force record delete"

Import-Csv .\ids_to_delete.csv | % { force record delete Object__c $_.Id }

It's not very fast, so if there's a lot of them you'll need to use the bulk API.  First remove the quotes from the CSV, no idea why, but "force bulk" hates them for some reason.  Then call it like this:

force bulk delete Object__c .\ids_to_delete.csv

If you just have a medium-sized list of IDs to delete and they're not in a CSV (e.g. copypasta from elsewhere), just paste them right into the command line as one big string and .Split() them, like this:

"axxx000000xxxxxAAA axxx…