Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wr/hard delete #959

Merged
merged 6 commits into from
Jun 14, 2024
Merged

Wr/hard delete #959

merged 6 commits into from
Jun 14, 2024

Conversation

WillieRuemmele
Copy link
Contributor

What does this PR do?

adds a --hard-delete flag to data:delete:bulk from discussion forcedotcom/cli#2904
adds data:delete:bulk UTs, NUTs seemed too hard to setup given user permission requirements

massages server error when user isn't permitted to help self-diagnose

What issues does this PR fix or reference?

@W-15903600@

@WillieRuemmele WillieRuemmele requested a review from a team as a code owner June 13, 2024 20:29
Copy link
Contributor

@jshackell-sfdc jshackell-sfdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same language as in the MD docs.

@@ -16,4 +16,12 @@ When you execute this command, it starts a job, displays the ID, and then immedi

- Bulk delete records from a custom object in an org with alias my-scratch and wait 5 minutes for the command to complete:

<%= config.bin %> <%= command.id %> --sobject MyObject__c --file files/delete.csv --wait 5 --target-org my-scratch
<%= config.bin %> <%= command.id %> --sobject MyObject\_\_c --file files/delete.csv --wait 5 --target-org my-scratch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<%= config.bin %> <%= command.id %> --sobject MyObject\_\_c --file files/delete.csv --wait 5 --target-org my-scratch
<%= config.bin %> <%= command.id %> --sobject MyObject__c --file files/delete.csv --wait 5 --target-org my-scratch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WillieRuemmele , please ensure that this doesn't get changed again -- there's something in an IDE that automatically switches "__c" to "\_\_c" so we need to be vigilant :)


# flags.hard-delete.summary

summary for Juliet here :)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
summary for Juliet here :)
Mark the records as immediately eligible for deletion by your org. If you don't specify this flag, the deleted records go into the Recycle Bin.


# flags.hard-delete.description

description here :)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description here :)
You must have the "Bulk API Hard Delete" system permission to use this flag. The permission is disabled by default and can be enabled only by a system administrator.

@cristiand391
Copy link
Member

cristiand391 commented Jun 14, 2024

QA notes:

setup

dreamhouse project with this csv of accounts to insert:

NAME,TYPE,PHONE,WEBSITE,ANNUALREVENUE
account Upsert #0,Account,415-555-0000,http://www.accountUpsert0.com,0
account Upsert #1,Account,415-555-0000,http://www.accountUpsert1.com,1000
account Upsert #2,Account,415-555-0000,http://www.accountUpsert2.com,2000
account Upsert #3,Account,415-555-0000,http://www.accountUpsert3.com,3000
account Upsert #4,Account,415-555-0000,http://www.accountUpsert4.com,4000
account Upsert #5,Account,415-555-0000,http://www.accountUpsert5.com,5000
account Upsert #6,Account,415-555-0000,http://www.accountUpsert6.com,6000
account Upsert #7,Account,415-555-0000,http://www.accountUpsert7.com,7000
account Upsert #8,Account,415-555-0000,http://www.accountUpsert8.com,8000
account Upsert #9,Account,415-555-0000,http://www.accountUpsert9.com,9000

then generate a csv for deletion running:

sf data query -q "SELECT Id FROM Account WHERE Name != 'Sample Account for Entitlements'" --result-format csv > deleteAccounts.csv

used default sysadmin profile with no hard-delete perms and a clone of the same profile with hard-delete enabled and a new user with that profile assigned.

data upsert bulk defaults to the "soft" delete, can see in recycle bin
data upsert bulk --hard-delete without the enough perms show help message:

➜  dreamhouse-lwc git:(main) ✗ sf data delete bulk --file deleteAccounts.csv --wait 5 --sobject Account --hard-dele
te
 ›   Warning: @salesforce/plugin-data is a linked ESM module and cannot be auto-transpiled. Existing compiled
 ›   source will be used instead.
Running bulk hardDelete request... done
Error (1): You must have the "Bulk API Hard Delete" system permission to use the --hard-delete flag. This permissio
n is disabled by default and can be enabled only by a system administrator.

➜  dreamhouse-lwc git:(main) ✗ echo $?
1

data upsert bulk --hard-delete with perms, hard-deletes records (don't show up in org's recycle bin).

➜  dreamhouse-lwc git:(main) ✗ sf data delete bulk --file deleteAccounts.csv --wait 5 --sobject Account --hard-de
lete --target-org 1718395769687_test-r52qahbcfpwj@example.com
 ›   Warning: @salesforce/plugin-data is a linked ESM module and cannot be auto-transpiled. Existing compiled
 ›   source will be used instead.

Job 750Ea00000A1ujxIAB | Status Job Complete | Records processed 10 | Records failed 0
Running bulk hardDelete request... done

🟡 can resume after a timeout but sf isn't printing the instructions on how to resume it like data query does:

➜  dreamhouse-lwc git:(main) ✗ sf data delete bulk --file deleteAccounts.csv --sobject Account --hard-delete --target-org 1718395769687_test-r52qahbcfpwj@example.com --wa
it 1
 ›   Warning: @salesforce/plugin-data is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
Running bulk hardDelete request... done
Error (1): Polling timed out after 57445ms. Job Id = 750Ea00000A1qGbIAJ

➜  dreamhouse-lwc git:(main) ✗ sf data delete resume --job-id 750Ea00000A1qGbIAJ
 ›   Warning: @salesforce/plugin-data is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
Getting status... done

Job 750Ea00000A1qGbIAJ | Status Job Complete | Records processed 76400 | Records failed 0

https://github.com/salesforcecli/plugin-data/blob/main/messages/batcher.md#timeout

EDIT
created W-16010988 to track improving timeout instructions in both delete/upsert bulk. commands.

@cristiand391 cristiand391 merged commit 9062ff6 into main Jun 14, 2024
12 checks passed
@cristiand391 cristiand391 deleted the wr/hardDelete branch June 14, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants