+ Start a Discussion
Julianne TajubaJulianne Tajuba 

Apex/Visualforce Newbie and Change Set Errors

I am very new to writing apex code and have come to a roadblock when it comes to moving the updated Visualforce page I've helped edit out of the sandbox and into production. When I created the changeset I added the visual force page and associate apex class that I've been working in. When I went to validate this change set in production I got several component errors. Namely that a certain variable doesn't exist and that the apex class I thought I'd created didn't exist as well.

Below I've attached the code where several of the errors exist namely that the Variable: Special_Skills__c doesn't exist. I have done some trailheads and googled other questions to get to the point where the visualforce page created is exactly what we are looking for. I just need some help in overcoming these errors so that I can get this into production ASAP in addition to increasing my knowledge of code and working in a sandbox and ultimately transferring this information into production. Thanks in advance!

//get the multi-select pick list values
    public List<SelectOption> MPOptions3 {
     get {
       List<SelectOption> options = new List<SelectOption>();
       
       DescribeFieldResult SpecialSkills = Schema.account.Special_Skills__c.getDescribe();  
     
       List<Schema.PicklistEntry> f = SpecialSkills.getPicklistValues();
       Integer listSize = f.size();
         
       for(Schema.PicklistEntry a : f) {
           options.add(new SelectOption(a.getValue(), a.getLabel()));
        } 
       return options;
     }  
     set;
    }

    
    //get and set the multi-select pick list as checkboxes
       public String[] MPItems3 { 
     get {
        String[] selected = new List<String>();
        List<SelectOption> sos = this.MPOptions;
        for(SelectOption s : sos) {
        if (this.account.Special_Skills__c !=null && this.account.Special_Skills__c.contains(s.getValue()))
           selected.add(s.getValue());
        }
        return selected;
     }public set {
        String selectedCheckBox = '';
        for(String s : value) {
         if (selectedCheckBox == '') 
           selectedCheckBox += s;
         else selectedCheckBox += ';' + s;
        }
        account.Special_Skills__c = selectedCheckBox;
     }
   } 
   
 
Best Answer chosen by Julianne Tajuba
Rishab TyagiRishab Tyagi
Hello Julianne,

I this field 'Special_Skills__c' happen to be a field that you created in sandbox environment? If so then you'll need to add this field to the change set as well, as I believe that this field must not be existing in the production org. Due to this error, your apex class also fails to deploy which will give the error [Apex class does not exist]: Dependent class is invalid... or some sorts.

Please verify that this field exists in your production environment.

Hope that answers your question.

All Answers

Rishab TyagiRishab Tyagi
Hello Julianne,

I this field 'Special_Skills__c' happen to be a field that you created in sandbox environment? If so then you'll need to add this field to the change set as well, as I believe that this field must not be existing in the production org. Due to this error, your apex class also fails to deploy which will give the error [Apex class does not exist]: Dependent class is invalid... or some sorts.

Please verify that this field exists in your production environment.

Hope that answers your question.
This was selected as the best answer
Julianne TajubaJulianne Tajuba
Thanks for the reply. It is not in the production environment, the field was newly created in the Sandbox.
Rishab TyagiRishab Tyagi
Hello Julianne,

I appreciate that you have managed to pinpoint the issue here. I would advice adding the field to the change set and then deploying it again. If you believe that my answer was helpful then please mark it as the best answer and close the question.
Deepali KulshresthaDeepali Kulshrestha
Hi Julianne,

There is a field 'Special_Skills__c' which you have created in the sandbox environment and used in the Vf page. You may be facing the error due to the absence of this field in the production environment. For this, you have to add this field in the changeset for adding it into the production.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha