2

So as a standalone, my lightning component works fine, I set on the component ( in the aura class impelements force:hasrecordid)

<aura:attribute name="recordId" type="Id" />

and in my controller have

({

    getResponse : function(component) {

        var action = component.get("c.getCalloutResponseContents");

        action.setParams({
            contactId: component.get("v.recordId")
        });

this works great as a standalone lightning component

however when i attempt to use a lightning out app that uses a visual force page, it does not work

the visualforce page code is this

<apex:page >
<apex:includeLightning />   


    <div id="lightning" />

    <script>
    //Tell your Visualforce page to use ExposeVF Lightning app
        $Lightning.use("c:wjrizzi_try3", function() {
            // Write a function that creates the component on the page
          $Lightning.createComponent("c:recent_giving",
          {
              "contactId" : recordId
           },
          "lightning",
          function(cmp) {
            // do some stuff
          });
        });
    </script>

</apex:page>

i get the error: recordID not found

i have tried the following in the lightning use create component to try to get that variable, none have succeeded

contactId : "{!v.recordId}"
recordId : "contactId"
"recordId" : contactID

you get the picture

as always any help would be most appreciated

1 Answer 1

12

When creating the component in the lightning out you need to manually pass in the recordId. How you get that Id depends the same things that are relevant to VF today.

So something like this assuming the ID is in the url

$Lightning.use("c:wjrizzi_try3", function() {
            // Write a function that creates the component on the page
          $Lightning.createComponent("c:recent_giving",
          {
              "recordId" : "{!$CurrentPage.parameters.id}"
           },
          "lightning",
          function(cmp) {
            // do some stuff
          });
        });

Your use of {!$CurrentPage.parameters.id} or a value from your controller or the Standardcontroller like Account.Id all depends on how your VF is set up and the entry point

2
  • i take that back, {!$CurrentPage.parameters.id} did work...you mentioned which method the VF is setup for, where do i look at that
    – Jay Rizzi
    Commented Apr 26, 2017 at 15:30
  • @JayRizzi - There are several possibilities as mentioned in my answer. This becomes a VF question and not lightning.
    – Eric
    Commented Apr 26, 2017 at 15:38

You must log in to answer this question.

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