Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have a managed-package VF page that has a button which calls the page controller's method. While i can go to the page and click that button to invoke managed code, I would like to invoke it programmaticaly from my trigger.

Is there a way to do that? Maybe by simulating the page load and a button click usiing apex?


share|improve this question

2 Answers 2

up vote 4 down vote accepted

It very much depends on whether the author of the managed package intended the method to be called in this manner. If the page controller exposes the action behind the button globally, there may be a good chance that you can. Of course, there maybe other variables on the page and/or controller itself that might be required to make that method call successful. Sometimes the author of a managed package will provide an API so that consumers can call managed functionality.

The key thing though, will be the accessibility of the controller methods which you can see by viewing the class in Develop->Apex Classes and seeing which methods are public vs global. If the method you want to call is not global, you will be out of luck.

As per your idea, you could obtain the content of the page by calling the getContent() method on a PageReference instance (thus simulating the page 'load'), but there would be no way to simulate the button click from server side Apex.

share|improve this answer
Very well. I started down the PageReference.getContent() path, but then got stuck and didn't know what I could do after that. Thanks for the answer. –  Kirill Yunussov May 5 '14 at 12:53

We are the author of a managed package, which is installed at one of our clients org. We made all methods of a page controller global, as well as the controller itself. When we check this at client side we see all methods defined as global, but when we try to use them in a custom component, it says "Method is not visible". In a custom page it works fine.

Thanks in advance, any ideas are appreciated.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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