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
karthi_querieskarthi_queries 

How to disable apex class

Hi All,

I'm trying to disable apex class in my sandbox, i didn't find the way to deactivate this.

Appereciate your help.

Regards,

Karthik

bob_buzzardbob_buzzard

Are you using the Force.com IDE?  If so, you can edit the associated -meta.xml file and change the status attribute to Inactive.

Martha_SenetaMartha_Seneta

bob_buzzard,

 

I just tied your suggestion, but the IDE won't allow me to save the change back to the server -- I get the "dirty" error on my .cls file after saving the change to the .cls-meta.xml file, and I confirmed via the UI that the class was still listed as active.  Any other action I should be taking?

bob_buzzardbob_buzzard

That sounds like you are trying to save directly to production, which isn't allowed.  You'll need to disable it in a sandbox and deploy the disabled class via eclipse IDE or change sets.

Martha_SenetaMartha_Seneta

Nope, I'm trying to save to a Sandbox org -- just tried again, and still got the same "dirty" error.

bob_buzzardbob_buzzard

Ah - dirty may mean that the code has changed underneath you and thus your changes would conflict with the version on the server.  While you should be able to apply the changes through the synchronize perspective, I've not had much success going that route in the past.

 

What works for me is:

 

Copy your code to notepad or similar

Refresh the class from the server (right click, Force.com submenu -> refresh from server)

Re-apply changes and save.

cmd loadercmd loader

Hi Bob,

 

Can you post the meta.xml because i am new to eclipse.

 

Thanks

nagalakshminagalakshmi

Hi Bob,

 

I am change the status as inactive in meta.xml. i am getting error when i deploy the class. I am getting the error as' class can not be saved inactive'.

 

If i change  status inactive to false i am getting error as 'invalid version'. Can you please help me out. Thanks in advance.

 

Thanks,

cmdloader.