function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Greg WilsonGreg Wilson 

"Variable not visible" error in production, but fine in development

Hello developers,

Problem:
I get this error from one VisualForce page in my managed packaged when it runs from client orgs:

"Variable is not visible: [PackagePrefix.ControllerName].uploadedAttachments"

The managed package works great in development. 
Test classes achieve 100% code coverage of this controller.

Extra information:
The relevant controller uses VisualForce pages to allow the public to provide file attachments. They provide some reference details too. The controller uses the reference information to find relevant custom object records, and attach the file uploads to them as standard Salesforce.com attachments.

The error presents itself as an "Authorization Required" error to the user. By previewing the VisualForce page as the administrator, with Development Mode on, the real error message can be seen.

I'm puzzled that this gets through thorough testing in development, but fails in client installations.

The attribute is defined like this at the top of the class:
public Map<Integer,Attachment> uploadedAttachments {get;set;}

Later on it gets initiated like this in one method:
uploadedAttachments = new Map<Integer, Attachment>();
And then various get and put operations are applied.

Questions:
  • What could be the cause?
  • How can I investigate it?

Thank you.
Lokesh KumarLokesh Kumar
HI Greg,

It seems like the issue is with permission either via profile and permission set for the installed managed package. kindly verify the client profile and check the package license.

Steps to reproduce.....
1.Login as and admin and then try login as any client who is facing that error.
2.verify as a client if you are facing the same issue then the issue is from the system side.

Try and confirm....
Greg WilsonGreg Wilson
Hi Lokesh, 

Thanks for your idea. We also thought it was a permission problem at first. To rule that possibility out, we:

- Set the sharing org-wide default on every object to the most open setting (mostly public read/write).

- The relevant user is the site's guest user. That user has a profile with everything allowed (read / create / edit / delete / view-all & modify-all) on all the objects, and a permission set with full access to every field of every object. The site's guest user has an assigned license to the managed package.

Even the Admin user in a client org sees the same error. (By previewing the VisualForce page as the administrator, with Development Mode on.)

I guess all that rules out permission or sharing problems as the cause.

Thank you,

Greg.