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
RobinrobRobinrob 

Can objects/classes within a managed package be used by other classes in the same org?

Hi all. Thanks for reading.

 

My problem is this: i have a managed package installed on an org containing lots of useful classes and a couple of custom objects.

 

I have access to all of these classes & objects separately on another org, where I have written some other code utilising the useful classes and accessing the custom objects.

 

I now need to be able to deploy my code to the other org containing the managed package, by deploying only my classes.

 

I am unable to make the deployment because my classes cannot access the custom objects to start with.

 

Is there any way to acheive what i am trying to do?

 

Many thanks!

 

Robin

Best Answer chosen by Admin (Salesforce Developers) 
RobinrobRobinrob

Thanks for the responses. I did indeed need the classes, constructors & methods which I was referencing to all be declared as global.

 

On top of that, any class/custom object/field reference needed to be prefixed with the namespace prefix of the package.

 

E.g.:

 

prefix.ClassName

prefix.CustomObject__c

StandardObject.prefix__customfield__c

All Answers

bob_buzzardbob_buzzard

You should be able to access the objects, as long as your profile is set up correctly.  You can only access classes that are declared as global AFAIK.

cloudmaniacloudmania

Package should detect the required permission automatically if you do any DML operation in your apex class.

RobinrobRobinrob

Thanks for the responses. I did indeed need the classes, constructors & methods which I was referencing to all be declared as global.

 

On top of that, any class/custom object/field reference needed to be prefixed with the namespace prefix of the package.

 

E.g.:

 

prefix.ClassName

prefix.CustomObject__c

StandardObject.prefix__customfield__c

This was selected as the best answer