You need to sign in to do that
Don't have an account?
suri03081988
AURA Lightening Component : Record ID from VF page is not available in <aura:handler JS controller method
Hi All,
We are invoking the AURA component in VF page. We are passing record id from VF page to AURA component.
The issue is, this record id is not avaiable in JS controller init method. It showing as undefined
Code sample:
VF Page Code Sample:
<apex:page sidebar="false" showHeader="false" standardStylesheets="false">
<!-- Lightening Component code version starts -->
<apex:includeLightning />
<div id="LightningCompContainer" />
<script>
$Lightning.use("c:SampleAURA_App", function() {
$Lightning.createComponent("c:SampleAURA_Component", {
},
"LightningCompContainer",
function(component) {
component.set("v.QuoteIDFromVfPage",'{!$CurrentPage.parameters.id}');
});
});
</script>
</apex:page>
AURA Lightening Component Code Sample:
<aura:component implements="force:appHostable" access="global" >
<!-- Handler - Init Method -->
<aura:handler name="init" value="{!this}" action="{!c.initLoad}"/>
</aura:component>
JS Controller Code Sample:
({
initLoad : function(component, event, helper) {
//Created var that store the recordIds of selected rows.
var recordid = component.get("v.QuoteIDFromVfPage");
alert('====>'+recordid);
},
})
Final result is: Alert popup is showing "undefined"
One observation is:
This ID is not avoilable only in init method. The record ID is available in other JS controller methods which are triggerd from button.
Please help me on this issue
Thanks in advance,
Surendra
We are invoking the AURA component in VF page. We are passing record id from VF page to AURA component.
The issue is, this record id is not avaiable in JS controller init method. It showing as undefined
Code sample:
VF Page Code Sample:
<apex:page sidebar="false" showHeader="false" standardStylesheets="false">
<!-- Lightening Component code version starts -->
<apex:includeLightning />
<div id="LightningCompContainer" />
<script>
$Lightning.use("c:SampleAURA_App", function() {
$Lightning.createComponent("c:SampleAURA_Component", {
},
"LightningCompContainer",
function(component) {
component.set("v.QuoteIDFromVfPage",'{!$CurrentPage.parameters.id}');
});
});
</script>
</apex:page>
AURA Lightening Component Code Sample:
<aura:component implements="force:appHostable" access="global" >
<!-- Handler - Init Method -->
<aura:handler name="init" value="{!this}" action="{!c.initLoad}"/>
</aura:component>
JS Controller Code Sample:
({
initLoad : function(component, event, helper) {
//Created var that store the recordIds of selected rows.
var recordid = component.get("v.QuoteIDFromVfPage");
alert('====>'+recordid);
},
})
Final result is: Alert popup is showing "undefined"
One observation is:
This ID is not avoilable only in init method. The record ID is available in other JS controller methods which are triggerd from button.
Please help me on this issue
Thanks in advance,
Surendra
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
All Answers
<aura:component implements="force:appHostable" access="global" >
<aura:attribute name="QuoteIDFromVfPage" type="string" access="global"/>
<!-- Handler - Init Method -->
<aura:handler name="init" value="{!this}" action="{!c.initLoad}"/>
</aura:component>
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Hi Mukesh,
its working, thank you so much for the help