I have a method in one class, but I need to move it out to another class.
I'm aware this question has been asked several times already, but I'm getting an error I don't understand.
How can I call a method from a different class?
Like so:
global with sharing class FirstController extends ThirdController{
public List<Task> getListOfObjects() {
SecondController sc = new SecondController();
return sc.getAllObjects();
}
}
global with sharing class SecondController{
public List<Task> getAllObjects() {
List<Task> myObjects; =
(
//LOGIC
);
return myObjects;
}
}
I get the follwoing error:
Method does not exist or incorrect signature: [SecondController].getAllObjects() FirstController.cls
Is there a mistake somewhere I can't see?
Any advice or suggestions would be greatly appreciated!
Best Answer
This is what I did and am able save the class and make a call to the method in the FirstController which subsequently calls the SecondController.
I am not sure what your ThirdController class was so I took it out from my code.
This works just perfectly.