+ Start a Discussion
SFDC Learning 6SFDC Learning 6 

Lightning Component display using VFpage

I was working with SOBject Lookup Lightning component using this link:https://meltedwires.com/2015/10/27/salesforce-lightning-lookup-component/
Its working cool!!but now i want to display this component via vfpage.Actually I have written this code:

 
<apex:page standardController="Opportunity">
 <apex:includeLightning />

    <div id="myDivId"/> 



  <script>
        $Lightning.use("c:Lookup", function() {
          $Lightning.createComponent("c:AccountLookup",
          { label : "" },
          "myDivId",
          function(cmp) {
            // do some stuff
          });
        });
    </script>




</apex:page>


Can anyone Help me with it! Thanksin advance!!
GulshanRajGulshanRaj
Hi,

I trust this code you copied from here (https://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_lightning_lc_for_vf.htm) . I wanted to bring in your notice that it is an example of creating dynamic button of type <ui:button which have some attribute like "label".

I would suggest you to kindly populate attributes of AccountLookup component. 
As I can see AccountLookup component have only one attribute i.e recordId, so code should be like this:
<apex:page standardController="Opportunity">
 <apex:includeLightning />

    <div id="myDivId"/> 



  <script>
        $Lightning.use("c:Lookup", function() {
          $Lightning.createComponent("c:AccountLookup",
          { recordId : "pass account ID here" },
          "myDivId",
          function(cmp) {
            // do some stuff
          });
        });
    </script>




</apex:page>
Please make it try and if this will work do not forget the mark this as SOLVED and the answer as the BEST answer, this will help others too.

All the best!!


Thanks
Gulshan Raj
GulshanRajGulshanRaj
Hi,

Is this works?

Please let me know if you have any question.

Thanks
Gulshan Raj
SFDC Learning 6SFDC Learning 6
Hi Gulshan Raj 11,

Thank you so much for reply, Actually it is working but we have to set events and attribute in visualforce page. Currently i am working on it. If you have better idea to do this please share!!

Again Many thanks 
GulshanRajGulshanRaj
Please follow this link https://salesforce.stackexchange.com/questions/106513/is-there-a-way-to-handle-a-lightning-event-from-a-visualforce-page-using-lightni

It will help you.

All the best!!

If it helps you, mark this question as solved and choose best answer so it help other in future to judge correct solution. 


Thanks
Gulshan Raj