function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ethanoneethanone 

How can I turn off all code?

My triggers and classes are getting in the way of using the data loader to load my data. If I make the triggers "inactive", my test coverage drops to 0% and I can't deploy the triggers in the inactive state.  Is there any way to turn off all code including classes (as if none existed)? And of course I'll need to put it all back afterwards.
Best Answer chosen by Admin (Salesforce Developers) 
ethanoneethanone
I successfully copied my code to my desktop, deleted from the sandbox, deployed the empty sandbox, imported my records, restored my sandbox code from the desktop and redeployed without a hitch.

All Answers

TehNrdTehNrd
Comment it all out but....... it sounds like there may be some issues with your trigger. Perhaps they are not setup for bulk operations.
Message Edited by TehNrd on 10-02-2009 04:51 PM
ethanoneethanone

They are set up for bulk, the problem is more one of data quality (fewer enforced rules on old system) and the fact that you can't load related at the same time as parent tables (example: our closed opportunities require at least one related record in a custom child table).

 

As far as solutions go, I've experimented with copying the classes folder to my desktop, deleting them and then copying them back.  It is much faster than touching each class by commenting them out, but it seems particularly heavy-handed.  Does anyone think this is a bad idea?

CaptainObviousCaptainObvious

Instead of deploying 'inactive triggers' from your sandbox to production, create a new Eclipse project directly from your production instance. Once you set the triggers to inactive, Save the changes (no need to deploy since you're already in production).

 

Remember to activate your triggers when you're done with Dataloader :smileyhappy:

ethanoneethanone

I just tried Captain Obvious's solution without success.  When I set the trigger metadata to "Inactive", I get save errors (file saved locally and not on server).  

 

On another front, I heard back from a SFDC tech who said I could save the classes and triggers to my desktop, delete them from my sandbox, deploy the classless and triggerless sandbox to production, run the dataloader, then copy the classes and triggers back to sandbox and redeploy. It makes me nervous, but I'm going to try it.

ethanoneethanone
I successfully copied my code to my desktop, deleted from the sandbox, deployed the empty sandbox, imported my records, restored my sandbox code from the desktop and redeployed without a hitch.
This was selected as the best answer
B2AB2A

Hi, Can you please explain how you deployed the Empty sandbox.  Not sure if I followed on this part.  How do you deploy no triggers (if that makes sense)?? 

 

I'm in the same situation and I was thinking of the idea of making my trigger inactive in sandbox and deploying the inactive trigger to production but not sure if that would work after hearing about code test coverage etc , and im definately not willing to "test" this out in a live instance of salesforce.

 

Help would be great!

 

B2A

CaptainObviousCaptainObvious

 

What a pain!
Instead of going through that whole re-deployment process, could you use a Custom Setting?
Create a checkbox in a custom setting which you can reference in your trigger. Then wrap all your code inside an if statement so that it only executes when the checkbox is checked. Something like this:

 

What a pain!


Instead of going through that whole re-deployment process, could you use a Custom Setting?

 

Create a isActive checkbox in a custom setting. Reference that checkbox in your trigger so that the code executes only when the checkbox is checked. Something like this:

 

 

trigger myTrigger on myObject__c (events){

    //Retrieve your custom setting
    MyCustomSetting__c dataSet = MyCustomSetting__c.getValues('TriggerSetting');
    Boolean triggerIsActive = dataSet.IsActive__c;

    if (triggerIsActive) {

        //Your code goes here

    }

}

 

With that in place, you'll be able to import your data by simply unchecking the box in the custom setting. The trigger will still fire, but no code will execute....

 

Good Luck!

 

ethanoneethanone

I did this a while ago, but If I recall correctly, i deleted the triggers from my sandbox and when i deployed to production, it deleted them from production. So in essense, an empty deploy is really a delete.

 

The custom setting option is probably safer, but I haven't used it since my "nuke the site from orbit" solution worked.  And I'm not familiar with custom settings, but i should be.