2

I've been trying to create a wrapper class for either SelectOptions and/or input checkboxes combined with pseudo Id's for both the checkbox and a Description text area input field to send to a Visualforce page (I need to toggle visibility on the text area). Everything I've tried has resulted in an Entity is not API accessible error message when I've attempted to save the class. I do have an account Id I can pass in the class (in actuality, only one) along with the 12 select options and could obtain the account object if necessary, but I still wouldn't have 12 unique accounts.

I've been attempting to use methods that looks something like this:

public class MultiTaskCreate{
    public list<sSelectOption>MS {get; set;}     
    public map<string,string>params;
    public SiteTaskSettings__c fsentries = SiteTaskSettings__c.getOrgDefaults();

    public MultiTaskCreate(){
        params = getparamsmap();
        getwrapper();
    }

    public map<string,string> getparamsmap(){
        map<string,string> p = ApexPages.currentPage().getParameters();
        return p;
    }

    public class aIds{
        public Id customerId {get; set;}
        public Id clientId {get; set;}

            public aIds(){
                map<string,string>prms = getparamsmap();
                Id cId = params.get('id');
                Id clId = params.get('clientId');                   
                this.customerId = cId;
                this.clientId = clId;
            }
        }


    //This method builds our list of SelectOptions
    public list<sSelectOption> getWrapper() {
        if(MS == null) {
            MS = new list<sSelectOption>();
            aIds acctIds = new aIds();
            string bId;
            string dId;
            SelectOption Opt;
            list<string>boxIds = new list<string>();
            list<string>descrIds = new list<string>();
            list<SelectOption>Options = new list<SelectOption>();
            String Descrip = '';
            Options = getOptionsList();

            for(integer i=0;i<Options.size();i++){ 

                if(i<10){
                    bId = '1100'+ string.valueOf(i); 
                    dId = '2100'+ string.ValueOf(i);

                }else if(i>=10){ // remove 1 digit from base number
                    bId = '110'+ string.valueOf(i); 
                    dId = '210'+ string.ValueOf(i);
                }

                boxIds.add(bId);
                descrIds.add(dId);
                Opt = Options[i];
                // As each Option is processed we create a new sSelectOption object and add it to the sSelectOption List
                MS.add(new sSelectOption(bId, acctIds, Opt, dId, Descrip));

            }

        }

        return MS;
    }

    public class sSelectOption {
        public string bId {get; set;}
        public aIds AD {get; set;}
        public SelectOption opt {get; set;}
        public string dId {get; set;}
        public string Descr {get; set;}

            public sSelectOption(string bId, aIds AD, SelectOption opt, string dId, string Descr){
                this.bId = bId;
                this.AD = AD;
                this.opt = opt;
                this.dId = dId;
                this.Descr = 'Description';
            }   
    }

    public list<SelectOption> getOptionsList(){
        list<string>valuesList = new list<string>();
        list<SelectOption>Values = new list<SelectOption>();
        string fSPE = string.valueOf(fsentries.Field_Service_PickEntries__c);
        valuesList = split.fSPE('(,)',0);
        for(string v:ValuesList){
            Values.add(new SelectOption(v,v));
        }     
        return Values;          
    }       

    public PageReference getRetURL(){

        string ReturnPage = ApexPages.currentPage().getParameters().get('retURL');

        return new PageReference(ReturnPage);
    }


    public PageReference processSelected() {

        // Place holder for collecting selected and assembling tasks
        // list<string>selectedOptions = new list<string>();
        // list<string>selectedDescr = new list<string>();
        // map<string,SelectOption>posOption = new map<string,SelectOption>();
        // map<string,string>posDesc = new map<string,string>();                

    }

}

From the options checked, multiple tasks will be created for the cId referencing the clientId. In my view, I don't even need to pass them as part of the wrapper, but I just happened to try it this time around since nothing else has seemed to work.

Based on this blog post by Mike Leach Salesforce Apex Wrapper Class and something @AndrewFawcett wrote in this answer to Visualforce Remoting - Passing wrapper class object as a parameter, its my impression they can only be written for sObjects. Can confirm this or demonstrate a method that works for something other than sObjects?

It's possible the issue I'm having is with trying to pass parameters through the class that aren't actual fields. At this point, I'm so frustrated I don't really know. To me, "selected" doesn't seem much different than a "state" or a "parameter" compared to the Id of a checkbox, but perhaps I'm mistaken.

10
  • 1
    I'm not completely following you here but in situations like this, I tend to selectively remove bits of code to truly understand where the offending line is. You refer to many variables outside of this method in the OP and this may be masking the the 'thorn among roses'
    – cropredy
    Nov 29, 2015 at 18:48
  • 1
    The term "wrapper" gets overused in the Apex world. You can certainly write all sorts of Apex classes with and without SObjects involved.
    – Keith C
    Nov 29, 2015 at 18:50
  • @crop. I've done exactly what you've suggested in trying to troubleshoot this. That's why I've posted. I couldn't find anything that I've declared improperly that would cause the issue and thus make it not API accessible. Stripped it down to the barest of bones at one point and still no joy.
    – crmprogdev
    Nov 29, 2015 at 18:51
  • The only thing I've not included in the code above is where the pagereferences come from to get the ids & declaration of public variables. I'll edit to include them.
    – crmprogdev
    Nov 29, 2015 at 18:54
  • Entity is not API Accessible - I've seen this before when I used an Sobject name as a custom type in some context where the compiler thought it could be a legitimate SObject type (e.g. Product instead of Product2 or myCustomProductType)
    – cropredy
    Nov 29, 2015 at 18:58

1 Answer 1

4

Here is the error:

valuesList = split.fSPE('(,)',0);

If you comment this out, the Entity is not API Accessible error goes away (other compiler errors are exposed). You probably wanted

valuesList = fSPE.split('(,)',0);

For some reason to the compiler, Split is an SFDC entity although I don't see it in the Object Reference Guide (nor is it an Apex reserved word)

Approach to solving this kind of problem:

  1. Take a backup of the code
  2. Start commenting out the bodies of the various methods until the Entity is not API Accessible goes away. The last method commented out is the one to look at in more detail.
  3. Inspect the offending method and, if that doesn't lead to the answer, selectively un-comment out lines of the method until the error reappears. The last line uncommented is likely to be the reason.

@crmprogdev - If this in fact resolves the issue, I'd suggest renaming the title of the OP to 'Entity Api is Not Accessible' as the issue has nothing to do with wrapper classes. In the code for the entire class below, error Entity is not API Accessible occurs:

public class Foo{
    list<string>valuesList = new list<string>();
  public Foo() {
    string fSPE ;
    valuesList = split.fSPE('(,)',0);  // Whoops! SFDC thinks Split is an 'entity' !
  }

}
2
  • That solved it! At one point I had moved the wrapper code without a list creation method (before adding accountIds) to another class, but had left that line in the main class. The wrapper compiled, but the main class still got that error. I've spent DAYS trying to find the source of this error. Thanks a load my friend!
    – crmprogdev
    Nov 30, 2015 at 14:41
  • my pleasure. I know how easy it gets to believe the problem is X despite the error message because we've been dealing with SFDC for so long that we've learned there can be misdirection at times. I've been in the same boat as you before and sometimes it just takes a fresh set of eyes. Plus, I have a special affinity to assist those who are strong contributors to the forum ("Band of Brothers/Sisters").
    – cropredy
    Nov 30, 2015 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .