2

I have a question . Let's say that i have a controller and a visualforce page in a Managed package . Can I make the controller so that it accesses the Custom object in the Org ( in which the package has been installed ) without exposing the controller at all ?

  • What do you mean by access? if that is query or dml data - you can do via dynamic query by fetching required sobjects and dml on it. Please, update your question according to site rules - stackoverflow.com/help/how-to-ask – kurunve Mar 16 '16 at 11:10
2

The controller in the managed package can have custom settings also in the managed package that nominates custom objects and custom fields that are not in the managed package to be queried/displayed/updated. (Describe calls can also be made to get more information.)

Dynamic SOQL has to be used for the querying and the get/put methods of the SObject base type used to access the data in Apex code. In Visualforce the map-like syntax then has to be used to identify a field:

<apex:repeat var="field" value="{! fields }">
    <apex:inputField value="{! sob[field] }"/>
</apex:repeat>

This only works if you know in advance what you want your controller to do with the custom object e.g. just display it and allow it to be edited so that the code can all pre-exist in the managed package.

  • Thanks for the info . I have one another question . I got the Dynamic SOQL part . But if my visualforce page has to be included in a Custom object's page layout then it's standard controller should match with the object . So how can i come over this situation ? I have to display one VF page in the page layouts of all custom objects . – Pruthvi Raj Mar 16 '16 at 14:51
  • @PruthviRaj The standardController attribute of an apex:page can't be an expression so the best you could do is include a component in your package that then has to be wrapped in a page that nominates the object. – Keith C Mar 16 '16 at 16:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.