function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ramana123Ramana123 

I want to pass the Record Ids from VisualForce page to lightening Component , Can Anyone help me in this.

How to pass RecordIds to listofAccounts in Component From Vf Page

VF PAGE : 
<apex:page standardController="Account" extensions="ListViewButtonController" recordSetVar="accs" >
</apex:page>

Controller : 
global class ListViewButtonController {
    List<SObject> selectedSobjects;
    Set<Id> recordIds;
    public String accIds;    
    global String evRespone { get; set; }    
    global ListViewButtonController(ApexPages.StandardController controller) {}    
    global ListViewButtonController(ApexPages.StandardSetController controller) {
        evRespone = '';
        selectedSobjects = controller.getSelected();
        recordIds = new Set<Id>();
        for(SObject singleRec : selectedSobjects) {
            recordIds.add(singleRec.Id);
        }
        System.debug(recordIds) ;
    }   
}

Component : 
<aura:component implements="lightning:isUrlAddressable">
    <aura:attribute name="listofAccounts" type="set" />
    
</aura:component>
 
Best Answer chosen by Ramana123
Suraj Tripathi 47Suraj Tripathi 47

Ramana,

You can take references from my code.

Vf page

<apex:page showHeader="false" sidebar="false" > 
   
      <apex:includeLightning /> 
    <div id="lightning" />   
<script>
    
     $Lightning.use("c:SeatimeSchedulerBookingAPP", function() {
                
                $Lightning.createComponent("c:SeatimeSchedulerBooking",
                                           {
                                               "recordId" :"{!$CurrentPage.parameters.recordId}"
                                           },
                                           
                                           "lightning",
                                           
                                           function(cmp) {
                                               console.log('Component Loaded');
                                                
                                           });
                
            });
    
   
    </script>
</apex:page>

App Name: SeatimeSchedulerBookingAPP

component Name: SeatimeSchedulerBooking

Component:

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

from vf page record id come to this AccIDFromVfPage and then you can use it 

Aura controller:

component.get('v.recordId')

please let me know it is working or not??

Please mark it as the Best Answer so that other people would take reference from it.

Thank You


 

All Answers

Suraj Tripathi 47Suraj Tripathi 47

Ramana,

You can take references from my code.

Vf page

<apex:page showHeader="false" sidebar="false" > 
   
      <apex:includeLightning /> 
    <div id="lightning" />   
<script>
    
     $Lightning.use("c:SeatimeSchedulerBookingAPP", function() {
                
                $Lightning.createComponent("c:SeatimeSchedulerBooking",
                                           {
                                               "recordId" :"{!$CurrentPage.parameters.recordId}"
                                           },
                                           
                                           "lightning",
                                           
                                           function(cmp) {
                                               console.log('Component Loaded');
                                                
                                           });
                
            });
    
   
    </script>
</apex:page>

App Name: SeatimeSchedulerBookingAPP

component Name: SeatimeSchedulerBooking

Component:

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

from vf page record id come to this AccIDFromVfPage and then you can use it 

Aura controller:

component.get('v.recordId')

please let me know it is working or not??

Please mark it as the Best Answer so that other people would take reference from it.

Thank You


 

This was selected as the best answer
RahulJoshi31RahulJoshi31
Hi Suraj,

In your code all is correct, but there is a problem in the code of "RecordId"

You are using !$CurrentPage.parameters.recordId but it is not working , so instead of "!$CurrentPage.parameters.recordId" it is $CurrentPage.parameters.Id. want to be