Feel like I am missing something here...I have a Global class in my Managed Package that I want to use to act as a simple wrapper to enable someone to have access to certain objects in my package.

As an example, the global class below is designed to make an instance of another class in the package called MyPublicClass available as a global variable called myResponse. The getMyData() method sets it to another instance of the same MyPublicClass generated by other methods in my package.

In the debug logs in an target installation org, I can see the all data for myResponse - but if I try and reference any individual variable in the myResponse class, I can get a Type not Visible error.

Do I need to make the myResponse class Global along with any variables I want to be able to access outside of the package? Just seems odd I can see the data in the debug logs but not access the actual variables?

global with sharing class MyExternalAccessWrapper {

global List<String> sFields;
global List<sObject> recordsforProcessing;
global MyPublicClass myResponse;

global Boolean getMyData() {

    KWD_Wrapper kwd = new KWD_Wrapper();
    kwd.sFields = sFields;
    kwd.objectsforProcessing = recordsforProcessing;
    try {
        myResponse = kwd.MyPublicClass;
        return TRUE;
    Catch (Exception Ex) {
        sErrorCode = Ex.getMessage();
        return FALSE;



1 Answer 1


That's correct. Adding the Global modifier makes the contents of the variable available outside the context of the class. The Global modifier on the class only makes the class available to other Apex code in the org.

From the Apex Docs

The global access modifier declares that this class is known by all Apex code everywhere. All classes that contain methods defined with the webService keyword must be declared as global. If a method or inner class is declared as global, the outer, top-level class must also be defined as global

As you can see, the above only refers to the class, not the variables/contents of the class. So any variables you want to make accessible must also be made global as well.

You must log in to answer this question.

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