1

I have a simple piece of code but I'm getting an error:

Compile Error: Method must define a body at line 28 column 25.

I'm new to Salesforce development and can't figure out this error

global with sharing class MyController {

    public String allSectors {
        get {
            List<String> sectors = GetSectors();
            allSectors = '';
            for (String i : sectors)
            {
                if (allSectors == '')
                {
                    allSectors = i;
                }
                else
                {
                    allSectors += ',' + i;
                }
            }
            return allSectors;
        }
        set;
    }

    public MyController()
    {
        //do something
    }

    public List<string> GetSectors();
    {
        List<String> sectorList = new List<String>();
        //populate list
        return sectorList;
    }

    @RemoteAction
    global static String GetSectorDetails(string sectorName)
    {       
        return 'something';
    }
}

Any help will be highly appreciated.

3

Remove ";" from

public List GetSectors();
. You can't have ";" for method names.

global with sharing class MyController {

    public String allSectors {
        get {
            List sectors = GetSectors();
            allSectors = '';
            for (String i : sectors)
            {
                if (allSectors == '')
                {
                    allSectors = i;
                }
                else
                {
                    allSectors += ',' + i;
                }
            }
            return allSectors;
        }
        set;
    }

    public MyController()
    {
        //do something
    }

    public List GetSectors()
    {
        List sectorList = new List();
        //populate list
        return sectorList;
    }

    @RemoteAction
    global static String GetSectorDetails(string sectorName)
    {       
        return 'something';
    }
}
  • oh crap, sometimes silly errors are over looked, thanks mate :) – user569925 Nov 12 '15 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.