I have embed existing legacy VF page inside a lightning component. In this page I am calling a remote method onload event for window. Here we are getting following error:

"Visualforce Remoting: Javascript proxies were not generated for controller abc: may not use public remoted methods inside an iframe."

If I declare all remote actions global this error resolved. But I don't want to go with this approach as solution because, to make all remote actions global I need to make classes as global also.

Is there any other way/approach to resolve this issue?

  • Solution for mentioned question is not applicable for me as I am calling a remote method onload event for window. I did commented on mentioned question but i was asked by moderator to post it as a separate question.
    – sfdcnoob
    Dec 11, 2018 at 17:16
  • What exactly is the objection to making the class global?
    – sfdcfox
    Dec 11, 2018 at 17:32
  • 1
    @sfdcnoob I think you're reading the guidelines a bit too literally. There are times when global is the appropriate solution. I've presented at least 3 other alternatives, but they may not be suitable for your code (can't tell without seeing your code). Sometimes something has to be global, because it's the only way. One thing that you should remember as a developer is that there are almost always reasons to break a "best practice"; an exception to the rule.
    – sfdcfox
    Dec 11, 2018 at 17:44
  • Hi Sir, I am just following Salesforce suggestion i.e."We recommend using the global access modifier rarely,". I want to make my code future proof, as it is possible that, some developer may add public remote method but it will work fine in classic. Also I need to embed few different pages in a lightning component, this means it is error prone and I need to inform everyone about these modifications. Also I have some restrictions in changing legacy code.
    – sfdcnoob
    Dec 11, 2018 at 17:47

1 Answer 1


The potential solutions are as follows.

apex:page action

You can use a page action to do something when the page loads.

Inline JSON

You can communicate values to the page by using a getter:

var pageData = {!config};


public String getConfig() {
  return JSON.serialize(...);

apex:commandLink, apex:actionFunction, etc

You can use any of the Visualforce components that have an action parameter. Check the documentation for more information.

@RemoteAction, webservice, etc

The class and appropriate methods must be global in this situation. There's no way around this restriction.

Ultimately, the solution depends on the reason why you're calling an onload method. You will need to make some alteration to the code, but exactly what that change is will depend on what the function does.

  • Hi Sir, thanks for your inputs ! I am aware about apex:page action and @RemoteAction, I was in the hope that, if still there is any other way/workaround to achieve the same. Also I have some restrictions in changing legacy code. It's always nice to have inputs from you, always looking forward to your answers. You never fail to enlighten and surprise us .
    – sfdcnoob
    Dec 11, 2018 at 17:54

You must log in to answer this question.

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