1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

salesforceのオブジェクト内のデータをsfdxコマンドですべて削除したい

Last updated at Posted at 2020-12-10

コマンド

sfdxコマンドを用いて以下コマンドで消去できます。
これでいちいちログインせずとも、カスタムオブジェクトの削除が可能になります。

sfdx force:data:soql:query -u ALIAS -q "SELECT id from CustomObject__c" -r csv > result.csv
sfdx force:data:bulk:delete -u ALIAS -s CustomObject__c -f ./result.csv
rm ./result.csv

Git Bashなどで叩く場合は、;でつなげてあげればワンライナーで実行できます。

解説

  • ALIASの部分は組織へのエイリアスを入力してください。
  • CustomObject__cの部分は削除したいオブジェクトのAPI名を入力してください。

sfdx force:data:soql:query -u ALIAS -q "SELECT id from CustomObject__c" -r csv > result.csv
これでカスタムオブジェクトのIDをcsv形式で取得します。

sfdx force:data:bulk:delete -u ALIAS -s CustomObject__c -f ./result.csv
これでcsv内のデータを削除します。

rm ./result.csv
これでcsvを削除してお掃除します。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?