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
RiothamusRiothamus 

Debugging code that works in Test, fails in Production

I have a trigger and associated apex classes that work correctly in Test, but give different (incorrect) results in Production. After going through each Apex file and comparing them in Production and Test, they appear to be identical.

 

What could cause this? What is the best way to debug?

 

What I'd like to do is just delete the Apex files from Production, and then upload a complete change set. How do I do this?

 

Suresh RaghuramSuresh Raghuram

Hi Riothamus,

 

you can not delete the apex code files directly from production.

 

Alternate for this is.

 

Go to the apex file in sanbox coment out all the code and save it. if any files that are dependent on the apex code you should do the same. and create a change set and deploy it. but make sure that will not effect any other process.

 

If you have any doubts, I am happy to help you.

 

Thanks,

Suree

RiothamusRiothamus
Hi Suree, Thank you. I think you are describing something that works in test does not deploy in production. I have hit this problem as well when I rename a class, and the dependencies that the old class relies on are broken. This problem, however, is different: the change set deploys successfully, but when a trigger runs the wrong results are saved. The trigger sets five data members, District (a lookup), District State, District Number, District Error, and District Error Detail. District State and District Number are combined to create District Name, but when the trigger runs in the district state and district number are left blank, andI the district id is stored in District Name. Very strange. I'm grasping at straws here, but the custom fields in production were entered manually instead of taken from deployment. Any chance that manual process would screw things up? Thanks, Art