7

I'm trying to pass a class name from a subscriber org up into a managed package, to make the package extensible. The package is going to use Type.forName(namespace, classname) to create an instance of the local class.

I've read this question:

Managed package can't access class defined in subscriber org via Type.forName

Which says that I just need to make sure that I include a blank string for the namespace, but that's not working for me.

Inside my managed package, I have:

global static Type forName(String namespace, String className) {
    return Type.forName(namespace, className);
}

Then, I try to call this from anonymous apex in the subscriber org:

System.debug(Type.forName('', 'PardotEmailTemplateWorker'));
System.debug(Nebula_API.NebulaApiWorker.forName('', 'PardotEmailTemplateWorker'));

Resulting in:

10:12:25.063 (63913068)|USER_DEBUG|[1]|DEBUG|PardotEmailTemplateWorker
10:12:25.065 (65727007)|USER_DEBUG|[2]|DEBUG|null

Any idea how I can move forward from here?

1 Answer 1

17

I'm an idiot: my local class, PardotEmailTemplateWorker, was not global.

Setting it to global solved the problem.

Hopefully, this will stand as a lesson to someone else in the future :)

1

You must log in to answer this question.

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