0

The use case is in a Lightning community page.

There are many Salesforce lightning components and we want to include a VF page where resides a custom Javascript code.

The Javascript code need to control the components.

$A.<GET_COMPONENT_A>.<UPDATE_ATTRIBUTE>

Is it possible?

If so, how could we get the Salesforce lightning component handler. Let's say the component name called 'CustLoginComponent'.

Use case: Try to manipulate the Salesforce lightning components on Chrome developer console.

If we create components dynamically, then we could save those components and access them later. However, in a lightning community page. I don't know how to find the component handler under this situation.

    var componentHdlr;

    $Lightning.use("c:SelfRegApp", function () {
        $Lightning.createComponent("c:SelfRegisterComponent",
            {                    
            },
            "reg",
            function (cmp) {
                // store the JS object and access it later
                componentHdlr = cmp;
            });
    });

Thanks so much!

inline

closed as too broad by glls, Boris Bachovski, Dave Humm, battery.cord, Himanshu Aug 4 '18 at 16:26

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Not only is your question too broad, but raises questions such as , why use a vf page and not a lightning cmp? Why? Additionally, have you attempted anything so far? Do you have any code you can share pointers MG as to where you are stuck? – glls Jul 31 '18 at 21:20
  • @glls Sorry for this poor ask. We have our own JS framework which could be only hosted inside a VF page. I'm not aware of any method which could access lightning component from an iFrame. – Dummy Jul 31 '18 at 22:18
1

In short, yes this is possible. There are some resources you could check for both, your VF page and Lightning component(s) to communicate in between themselves:

you will have to leverage the Window.postMessage() API for securely communicating between your components.

In the long run, you might want to consider updating your JS Framework to one supported in lightning + Locker service.

  • it's so nice that get feedbacks from you. Actually, I did go through the documentation you mentioned. However, the issues is still there. Let's say, what I'm wondering is how could I access the Salesforce lightning component using developer console. e.g. var a = $A.getFirstComponent; a.set ; a.get. – Dummy Jul 31 '18 at 23:13
  • i dont recommend following up in the comments and changing the questions everytme there is an update. You will have to follow up in a new Post and update with what you have tried, where you are stuck, what doesnt seem to work, etc etc...if you did follow some doc, make sure you mentioon it in your post and if possible in clude links towards them. – glls Jul 31 '18 at 23:19

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