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
Saurabh Bisht 8Saurabh Bisht 8 

How to get parentId in lightning action

I was fetching parentId through vfPage before the spring 18 updates, and it was working fine. But i'm not getting it now.... I was using this code..
VF Page:
<apex:page standardController="Custom_Object">
<div id="lightningCmp"/>
<apex:includeLightning />

<script>
        var b_id = '{!$CurrentPage.parameters.CF00N5D000000TJgE_lkid}';
        console.log('@@@@@@'+b_id);
        $Lightning.use("c:TestApp", function() {
            $Lightning.createComponent(
                "c:TestCmp",
                {"parentId":b_id},
                "lightningCmp",
                function(cmp) {
                    console.log("##");
                    //console.log(cmp);
                });
            });
       
</script>
</apex:page>

TestCmp:
<aura:attribute name="parentId" type="String"/>

TestController:
var pid = cmp,get("v.parentId");
alert(pid);

Not getting pid ...
I have to override the standard new button in lightning.

Can anyone help???
sfdcMonkey.comsfdcMonkey.com
hi saurabh, try below code :
<apex:page standardController="Custom_Object">
<div id="lightningCmp"/>
<apex:includeLightning />

<script>
        var b_id = '{!$CurrentPage.parameters.CF00N5D000000TJgE_lkid}';
        console.log('@@@@@@'+b_id);
        $Lightning.use("c:TestApp", function() {
            $Lightning.createComponent(
                "c:TestCmp",
                {},
                "lightningCmp",
                function(cmp) {
                    console.log("##");
                    cmp.set("v.parentId" , b_id);
                });
            });
       
</script>
</apex:page>

http://​http://sfdcmonkey.com/2017/08/19/display-lightning-component-visualforce-page/

i hope it helps you.
      Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others, thanks 
sfdcmonkey.com 
Saurabh Bisht 8Saurabh Bisht 8

Hi Piyush ,
Thanks for your quick response... but it didn't work..
I'm not getting anything in b_id;
I think, it's because salesforce has changed it's URL format... and i'm not getting parentId in URL (https://<domainName>...........?CF00N5D000000TJgE_lkid = <parientId>) , which earlier I was getting.
Any alternative for this.....?
 
sfdcMonkey.comsfdcMonkey.com
are you getting the parentid in debug log on line number 7 =  console.log('@@@@@@'+b_id); ?
Saurabh Bisht 8Saurabh Bisht 8
Nope.. 
because i'm not getting CF00N5D000000TJgE_lkid  parameter anymore in the URL
sfdcMonkey.comsfdcMonkey.com
how you are check or open this VF page ?? 
 
Saurabh Bisht 8Saurabh Bisht 8
I have call this VF page in standard new button, to override the functionality and to call my lightning cmp on the New button/action.
Saurabh Bisht 8Saurabh Bisht 8
Can anyone help on this issue.... ??? 
It's urgent .
Thanks in advance.