1

I am planning to create List button using lightning out, however I am not sure how to get the record Id dynamically from the VF page and pass it to Lightning Component.

<!-- This VF page hosts a Lightning Component. -->
<apex:page standardcontroller="Opportunity" recordSetVar="cons"
    showHeader="true"
    sidebar="false"
    standardStylesheets="false">

  <!-- Load Lightning dependencies -->
  <apex:includeLightning />

  <div class="slds">
    <!-- Target div for the Lightning component -->
    <div id="customObjectEdit"></div>
  </div>

  <script>
    var recordId = '0030v000001VfqhAAC';

    $Lightning.use("c:createLtgOutApp", function() {
      var attributes = {
        recordId: recordId
      };

      var targetElementId = 'customObjectEdit';

      $Lightning.createComponent('c:createLtgOut', attributes, targetElementId,
        function(cmp) {
          // At this point the component has been created and loaded
      });
    });
  </script>
</apex:page>

This is the Opportunity list button which I am using it on Contact page. How do I get the Contact record Id dynamically here and pass it to Component attribute?

Is this the right approach or is there any other option do I have for related list button to prepopulate the values?

I guess, I have to write another extension controller to get the id of the record.

-1

Figured out the way to get the id, I used the extension controller to get the id of the record.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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