+ Start a Discussion
Eager-2-LearnEager-2-Learn 

How to disable apex code in production?

Hello,


I actually have two questions around apex code.

 

  1. Suppose I want to turn off or delete my apex class, how do I go about doing that in production?  I do not see a way to deactivate or delete the code?
  2. Prior to installing the DupeBlocker 2.0 application in the Sandbox my code was at 89% code coverage but after I installed the third party application it dropped to 23%!  I see that SFDC is using some of the DupBlocker code classes that are firing when I run my test script.  What will I do to get around this because once I install DupeBlock into production I will be faced with this kind of mishap all the time!!!
Best Answer chosen by Admin (Salesforce Developers) 
NaishadhNaishadh

yes, but make sure that you deploy apex class with test code.

All Answers

marioluisscmarioluissc

1 - For disable your apex class, you shoud to go to Sandbox. There, when you open your class, will have the option "Active", then turn off,  and redeploy to Production Base.

2 - Contact the company for them to update the package so you get 100% in tests.

 

 

I hope I have helped you,

 

Eager-2-LearnEager-2-Learn

Thank you for the feedback.

 

When you say 'company' do you mean SFDC or CRMFusion?

marioluisscmarioluissc

The owner of the package,  CRMFusion.

She will haves to do a new test class, because she build the application.

 

 

Eager-2-LearnEager-2-Learn

It is not clear to me how I would be able to get a company to create a special test class just for my situation.  That just doesn't sound right?  Can you please elaborate?

NaishadhNaishadh

Is DupBlocker a managed package?

Eager-2-LearnEager-2-Learn

When you say managed if you mean do I have access to any of the code?  I do not have access to see or change any of the code so I would think it is managed?

 

This what CRMfusion told me.  I don't like the idea of using an non-user friendly tool like Ant!  I am still learning how to code in Apex!


Does CRMfusion's answer sound acceptable to you?

 

Your low test coverage is due to how Salesforce detects code dependencies and their related unit tests.  You'll need to go to Setup->Develop->Apex Classes and choose Run All Tests from that screen to validate your full test coverage and verify you're above 75%.  Alternatively, you could just run your unit tests as you are now and verify that every class and trigger is at or above 75% coverage.

 

You should be able to deploy your code to production without issue as long as you've verified the coverage of the individual classes and triggers.  If you run into an issue with a DupeBlocker unit test failing during deployment there are a couple of different methods you could utilize to get around this.  The primary method is to use the Force.com Migration Tool and add a runAllTests="false" parameter to your deployment target.

 

You might also try creating a changeset for your code and deploying that changeset to your production org.

 

Using the Force.com Migration Tool is Salesforce's recommended method for situations like this.  The tool and documentation can be found here: http://wiki.developerforce.com/index.php/Force.com_Migration_Tool

NaishadhNaishadh

you don't need to worry about code coverage as long as it is a managed package.  While deploying your code in production SF will only check code coverage for your code not for managed package code. 

Eager-2-LearnEager-2-Learn

So to be clear, even though in the Sandbox it says 23% and that 66% loss is coming from CRMfusion code it will still deploy because SFDC knows to disreguard the 66% which would put me back to my 89% prior to installing DupeBlocker in the Sandbox?

 

If the answer to that is true then why does SFDC do that in the sandbox when testing instead of making me get an ulcer over another road block that I have been telling my sup that I am facing.  :smileyvery-happy:

 

NaishadhNaishadh

yes, but make sure that you deploy apex class with test code.

This was selected as the best answer
randombardrandombard

What if when you goto the apex class you cant change the "active" setting?

 

Or am I being blind, when I double click/edit cant make any changes

AwkwardTacoAwkwardTaco

I, too, am not seeing the ability to disable the class.

Eager-2-LearnEager-2-Learn

In your Sandbox ORG if you go into Edit Mode on the code you want to make inactive then save the Active checkbox becomes unchecked.  I am guessing that after you deploy to production while it is unchecked in your Sandbox ORG it will remain unchecked.  I have not confirmed that step!

 

I remember recently using Eclipse to get into the Production ORG and then made a very simple change to a class.  I changed a static word from 'closed' to 'close' and updated my comments.  When I saved it back to production I noticed the Active checkbox was unchecked when I logged into Production.  From production I executed the associated test script and the active checkbox became checked.  This may be another avenue to get get something inactive, just don't reexecute the associated test code.

 

I hope this helps.

VKrishVKrish

I tried the solution. Its not working!

The 'Is active' checkbox is available to edit only in triggers and not in class in sandbox.

I tried commenting all the code of the class except the signature; I also tried deleting the class in sandbox. But I want to deactivate it in sandbox. Is there any workaround?

Jancy MaryJancy Mary
Hi,

I need a small confirmation here on this wall, if I understood this conversation correct we can deactivate the Trigger (whether its a custom defined trigger or a trigger from a managed package) through eclipse force.com IDE by changing the status on double click of xxXXX.trigger-meta.xml file from Active to Inactive.

Thanks,
Jancy