How can I delete all CiviCRM Campaigns without having to delete one at a time? I have over 500 of them. Is there a way to do this with the API explorer?
The API Explorer will only delete one at a time, unfortunately.
If you have command-line access,
cv is a nice way to access the API to do this. You can run a command line:
cv api Campaign.delete id=1.
Sometimes if I'm feeling lazy and I don't want to code something to mass delete, I'll do the following:
- Open a spreadsheet program.
- In column A, start filling in numbers: 1, 2, 3.
- Select those cells and then drag. LibreOffice Calc, Google Sheets and Excel all know that you want to continue the series. Continue until you have however many rows you need (in your case, over 500).
- In Cell B1, put the following formula:
="cv api Campaign.delete id=" & A1
- Copy/paste that down all of column B. The end result is that you'll have 500+ lines that will each delete a single campaign.
- Copy Column B, then paste it into a command line terminal.