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
Bert Van HoveBert Van Hove 

getrecord() returns NULL in Lightning

Hi guys,

i'm working on a project where I use a visualforcepage, a standardcontroller for opportunity and extend it with an apex class.
The apex class gets the AccountId from the current Account via getRecord().
This works perfect in Classic mode, but in Lightning getRecord() returns NULL.

Any ideas?
Thanks in advance
Best Answer chosen by Bert Van Hove
SandhyaSandhya (Salesforce Developers) 
Hi,

The Apex controller has no knowledge of the request that went to the browser, all it has is information that has been passed to the method call. You'll need to get the record in the lightning component, which is what the 'force:hasRecordId' interface is for:

https://developer.salesforce.com/blogs/developer-relations/2015/11/building-context-aware-lightning-components.html
 
https://developer.salesforce.com/forums/?id=906F0000000BawjIAC
 
Best Regards,
Sandhya

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

The Apex controller has no knowledge of the request that went to the browser, all it has is information that has been passed to the method call. You'll need to get the record in the lightning component, which is what the 'force:hasRecordId' interface is for:

https://developer.salesforce.com/blogs/developer-relations/2015/11/building-context-aware-lightning-components.html
 
https://developer.salesforce.com/forums/?id=906F0000000BawjIAC
 
Best Regards,
Sandhya
This was selected as the best answer
Bert Van HoveBert Van Hove
Hi Sandhya,

Thanks for your fast reply, i'm gonna try and figure out how to combine lightning components with the existing VFP, since I'm pretty new on these domains