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
jnegijnegi 

Lightning Event inside VF page

Hi All,

I am using lighning component in VF page using lightning out. Created simple datatable with Edit and Del option for each record. Now when I click on Edit link on each row, able to pass selected record Id to controller however not able to use below event code to edit the record. Getting undefined in console.log.
 
var editRecordEvent = $A.get("e.force:editRecord");    
console.log('***JN***'+editRecordEvent);
    editRecordEvent.setParams({
         "recordId": recId // recId is populating correctly
   });
    editRecordEvent.fire();

Any idea?

Thanks
Jagmohan
Best Answer chosen by jnegi
Jayant DasJayant Das
Hi Jagmohan,

The documentation refers that the event is handled by "one.app" container and works only in in Lightning Experience, the Salesforce app, and Lightning communities. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_editRecord.htm

You may further refer to this links for pointers:
https://salesforce.stackexchange.com/questions/152428/lightning-events-in-force-namespace-dont-work-inside-of-a-visualforce-page

Thanks,
Jayant

All Answers

Jayant DasJayant Das
Hi Jagmohan,

The documentation refers that the event is handled by "one.app" container and works only in in Lightning Experience, the Salesforce app, and Lightning communities. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_editRecord.htm

You may further refer to this links for pointers:
https://salesforce.stackexchange.com/questions/152428/lightning-events-in-force-namespace-dont-work-inside-of-a-visualforce-page

Thanks,
Jayant
This was selected as the best answer
Ashif KhanAshif Khan
Hi jnegi,

with visualforce page in lightning component you need to use 

just replace code with
 
sforce.one.editRecord(recId);

Regards
Ashif
bhanu_prakashbhanu_prakash
Hi Jengi,

check out below link
http://cloudyworlds.blogspot.in/2016/02/lightning-events-via-visualforce.html
let us know if it helps you and mark it best if it helps you

Thanks, 
Bhanu Prakash
visit ForceLearn (https://www.forcelearn.com) for salesforce Latest Updates and development tips
jnegijnegi
Thank you everyone for your quick response!