0

I want to deploy the destructive changes. I have tried the below options but it doesn't work for me:

Option 1: sfdx force:mdapi:deploy -f destructiveChanges.zip -u orgname

Option 2: sfdx force:source:deploy --manifest .\destructiveChanges\package.xml --predestructivechanges .\destructiveChanges\destructiveChangesPre.xml

I have created a folder :

descrtuctiveChanges
  --package.xml
  --descrtuctiveChanges.xml
  --descrtuctiveChangesPre.xml(for force:source:deploy)

Earlier with a version(7.133.0) of sfdx cli the force:mdapi:deploy was working in Sandbox but not working in Production. So I have updated cli version today.

enter image description here

Now facing the below error in with above both commands:

ERROR running force:mdapi:deploy:  versions.map is not a function

enter image description here

My XML files are: package.xml

<?xml version="1.0" encoding="UTF-8"?>    
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>52.0</version>
</Package>

destructiveChanges.xml OR destructiveChangesPre.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Visit_Reports__c</members>
        <name>CustomObject</name>
    </types>
</Package>

And I also tried the zip file using workbench. I am able to delete the custom object on Sandbox with the option NoTestRun. But on production, it does not allow us to deploy with NoTestRun. Can anyone please suggest to me how I can achieve this?

enter image description here

Note: I tried by adding one test class in package.xml and adding that test class in src/classes/testclass and metadataOfTestclass - and then created a zip file with that but it gives me an error:

No Package.xml found

My pacakage.xml with test class:

<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Test_dalShift</members>
        <name>ApexClass</name>
    </types>
    <version>52.0</version>
</Package>

And inside src, I have test class added as given here

enter image description here

Also tried with RunLocalTest, but same issue.

Please help me here. Thanks

1
  • I started facing the same issue as well.
    – Rodrigo
    Commented Aug 29, 2022 at 23:36

1 Answer 1

0

Two steps I have tried. I am not sure which one worked for me, but posting as an answer here so that someone facing this type of issue can try this solution.

  1. Restart the VS Code, if this does not work then,
  2. Reinstall the SFDX CLI and restart the VS Code, if this does not work then,
  3. Uninstall Salesforce CLI -> Go to windows explorer and use this path "%LOCALAPPDATA%\sfdx" -> Delete all the files from there -> Reinstall Salesforce CLI

I think Step 2 was worked for me.

Also instead of sfdx force:mdapi:deploy, sfdx force:source:deploy worked for me.

Here I am posting the whole command:

 sfdx force:source:deploy --manifest .\destructiveChanges\package.xml --predestructivechanges .\destructiveChanges\destructiveChangesPre.xml --postdestructivechanges .\destructiveChanges\destructiveChangesPost.xml --targetusername Namespace --testlevel RunSpecifiedTests -r "Notest" -w 20

pacakge.xml is like below:

<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>YourApexClass</members>
        <name>ApexClass</name>
    </types>
    <version>52.0</version>
</Package>

destructiveChangesPost.xml & destructiveChangesPre.xml we can write like this:

<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>CustomObject__c</members>
        <name>CustomObject</name>
    </types>
</Package>

Here is the benefit of --testlevel RunSpecifiedTests -r "Notest"

If there is no test class that needs to run then we can give any text with -r option it will not run any test.

And if we want to deploy any Metadata then that will go in the package.xml and the files should be there with the folder structure as we have in VS Code in the same folder where the package.xml file we keep.

The folder structure will be like:

classes
   ClassA.cls
   ClassA.cls-meta.xml
   ClassATest.cls
   ClassATest.cls-meta.xml
package.xml
destructiveChangesPost.xml
destructiveChangesPre.xml

I had not checked/tried to find any solution for the Workbench yet.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .