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

Compile Error on inexisting code



I'm having trouble modifying and saving an Apex class.

When I'm saving it, I get an error message, but the indicated error line doesn't match the actual code in the class.

The error is matching the old version of the code, before I modify the class.


I tried to save the class using the ForceIDE and directly in the browser without success.

I also tried to recompile all classe but I fails because of the same error.


So I emptied all the code in the class, leaving only the declaration (see screenshot below), but the error message is still referencing the old code :(


Error: Compile Error: Variable does not exist: Constants.CONTACT at line 59 column 83




I seems like the old code is cached somehow, does anybody know how to handle this?






Hi Benj,


Can you share your old code.




Thanks for your answer. The original code sample looks like below, line 59 is highlighted.


The error on the old code is legit since the Constants class was removed and moved in another class.

The modification I'm trying to commit is precisely to reflect these changes.


The new class containing the Constant was successfully uploaded to the Org


    global static List<ChartItem> loadChartInfo(String ids) {
        String[] splitedIds = ids.split(',');
        String offerId = splitedIds[0];
        String userId = splitedIds[1];
        List<ChartItem> resultList = new List<ChartItem>();
        Map<String,String> view = Default360ViewGenerator.get360View(userId);
        ScoreCardModel model = new ScoreCardModel(offerId);
        Map<String, Double> varScoreMap = model.getScoreMap(view);
        Map<String, String> contactFieldMap = VariableChartController.getFieldMap(Constants.CONTACT);
        String contactLabel = VariableChartController.getObjectLabel(Constants.CONTACT);
        Map<String, String> leadFieldMap = VariableChartController.getFieldMap(Constants.LEAD);
        String leadLabel = VariableChartController.getObjectLabel(Constants.LEAD);
        Map<String, String> accountFieldMap = VariableChartController.getFieldMap(Constants.ACCOUNT);
        String accountLabel = VariableChartController.getObjectLabel(Constants.ACCOUNT);
        for (String var : varScoreMap.keySet()) {
            List<String> labelList = VariableChartController.generateLabels(var, contactLabel, contactFieldMap, leadLabel, leadFieldMap, accountLabel, accountFieldMap);
            String value = (view.get(var) == null || view.get(var) == '') ? 'missing' : view.get(var);
            ChartItem item = new ChartItem(labelList.get(0) +':'+ labelList.get(1) + labelList.get(2) + ':' + value,varScoreMap.get(var));
        return resultList;