2

CALLABLE

Enables developers to use a common interface to build loosely coupled integrations between Apex classes or triggers, even for code in separate packages.

I have created an LWC component and the controller for that is also inside Managed package (Package A).

And there is another managed package which we are building. (Package B)

Package A, has controller and I am using callable to call the class from Package B like this:

        private static final String STRING_TESTPAGECONTROLLERPE = 'TestPageControllerPE';
        Callable extension = (Callable) Type.forName(STRING_TESTPAGECONTROLLERPE).newInstance();
        List<TestWrapper> testWrappers =
                (List<TestWrapper>) extension.call('fetchTestArticles', new Map<String, Object> {});
        return testWrappers;  

The class TestPageControllerPE exists in Package B, and implements Callable and is defined as public.

Question : Can package A call class from package B without name space if the called class has callable interface and is public?

Question : If not, can I keep the class name in custom label (namespace.TestPageControllerPE), so that I can change the class name from custom label if the Package B name changes? Will there be any security constraints?

Your Answer

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

Browse other questions tagged or ask your own question.