project delete source
Delete source from your project and from a non-source-tracked org.
Use this command to delete components from orgs that don’t have source tracking. To remove deleted items from orgs that have source tracking enabled, “sf project deploy start”.
When you run this command, both the local source file and the metadata component in the org are deleted.
To delete multiple metadata components, either set multiple –metadata <name> flags or a single –metadata flag with multiple names separated by spaces. Enclose names that contain spaces in one set of double quotes. The same syntax applies to –source-dir.
force:source:delete
| Flag Name (Long) | Flag Name (Short) | Description |
|---|---|---|
‑‑api‑version | N/A | Type: Value Override the api version used for api requests made by this command |
‑‑check‑only | ‑c | Type: Boolean Validate delete command but don’t delete anything from the org or the local project. IMPORTANT: Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations. Validates the deleted metadata and runs all Apex tests, but prevents the deletion from being saved to the org. If you change a field type from Master-Detail to Lookup or vice versa, that change isn’t supported when using the –check-only flag to test a deletion (validation). This kind of change isn’t supported for test deletions to avoid the risk of data loss or corruption. If a change that isn’t supported for test deletions is included in a deletion package, the test deletion fails and issues an error. If your deletion package changes a field type from Master-Detail to Lookup or vice versa, you can still validate the changes prior to deploying to Production by performing a full deletion to another test Sandbox. A full deletion includes a validation of the changes as part of the deletion process. Note: A Metadata API deletion that includes Master-Detail relationships deletes all detail records in the Recycle Bin in the following cases. 1. For a deletion with a new Master-Detail field, soft delete (send to the Recycle Bin) all detail records before proceeding to delete the Master-Detail field, or the deletion fails. During the deletion, detail records are permanently deleted from the Recycle Bin and cannot be recovered. 2. For a deletion that converts a Lookup field relationship to a Master-Detail relationship, detail records must reference a master record or be soft-deleted (sent to the Recycle Bin) for the deletion to succeed. However, a successful deletion permanently deletes any detail records in the Recycle Bin. |
‑‑flags‑dir | N/A | Type: Value Import flag values from a directory. |
‑‑force‑overwrite | ‑f | Type: Boolean Ignore conflict warnings and overwrite changes to the org. |
‑‑json | N/A | Type: Boolean Format output as json. |
‑‑metadata | ‑m | Type: Value Metadata components to delete. If you specify this flag, don’t specify –source-dir. |
‑‑no‑prompt | ‑r | Type: Boolean Don’t prompt for delete confirmation. |
‑‑source‑dir | ‑p | Type: Value Source file paths to delete. The supplied paths can be a single file (in which case the operation is applied to only one file) or a folder (in which case the operation is applied to all metadata types in the directory and its sub-directories). If you specify this flag, don’t specify –metadata. |
‑‑target‑org | ‑o | Type: Value Required Username or alias of the target org. Not required if the target-org configuration variable is already set. |
‑‑test‑level | ‑l | Type: Value Valid Values: NoTestRun, RunSpecifiedTests, RunLocalTests, RunAllTestsInOrg, RunRelevantTestsDeployment Apex testing level. Valid values are:
If you don’t specify a test level, the default behavior depends on the contents of your deployment package and target org. For more information, see “Running Tests in a Deployment” (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deploy_running_tests.htm) in the “Metadata API Developer Guide”. |
‑‑tests | N/A | Type: Value Apex tests to run when –test-level is RunSpecifiedTests. If a test name contains a space, enclose it in double quotes. For multiple test names, use one of the following formats:
|
‑‑track‑source | ‑t | Type: Boolean If the delete succeeds, update the source tracking information. |
‑‑verbose | N/A | Type: Boolean Verbose output of the delete result. |
‑‑wait | ‑w | Type: Value Default value: 33 minutesNumber of minutes to wait for the command to finish. If the command continues to run after the wait period, the CLI returns control of the terminal window to you. |
Delete all local Apex source files and all Apex classes from the org with alias “my-scratch”:
Delete a specific Apex class and a Profile that has a space in it from your default org; don’t prompt for confirmation:
Run the tests that aren’t in any managed packages as part of the deletion; if the delete succeeds, and the org has source-tracking enabled, update the source tracking information:
Delete the Apex source files in a directory and the corresponding components from your default org: