+ Start a Discussion
penchala rajupenchala raju 

can any one solve this error


i got an error like "Method does not exist or incorrect signature: [Schema.ChildRelationship].getChildObject()"" in 14th line of the program


public class SchemaFieldExample {
list<selectoption> options;
  public list<selectoption>getoptions()
    {
        return options;
    }
    public SchemaFieldExample()
    {
        options=new list<selectoption>();
        schema.DescribeSObjectResult r=Account.SobjectType.getDescribe();
        list<schema.ChildRelationship> c=r.getChildRelationships();
        for(schema.ChildRelationship x:c)
        {
            String name=''+x.getChildObject();
            selectoption op=new selectoption(name,name);
            options.add(op);
        }
    }
    
}
pconpcon
It's because that method does not exist on the ChildRelationship class [1].  Not knowing what you are trying to do I'll just have to guess.  You either want the getRelationshipName()  or getChildSObject().getDescribe().getName()

[1] https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_class_Schema_ChildRelationship.htm
penchala rajupenchala raju
i am not getting the child objects for the account object after rectify the code 
penchala rajupenchala raju
got it.thank u
pconpcon
What did you end up doing?
Ketan Benegal 7Ketan Benegal 7
    You can either use getRelationshipName() method or getChildSObject().getDescribe().getName().

Please mark the question closed/solved if it is done.