+ Start a Discussion
Peter BölkePeter Bölke 

Problem with Action undefined

Hello,

we are on lightning and on a custom record page i have button which is linked to VF-Page. This page hold two lightning componenten and two VF-componnent.
I have an issue with the lightning components there is another button which shouuld open another component, but i fails with:
 
TypeError: Cannot read property 'setParams' of undefined

and this is the code what causes this exception:
 
var action1 = $A.get("e.force:navigateToComponent");
action1.setParams({
    componentDef: "c:LtngBusinessPotentialsViewAllComp", 
    componentAttributes: { 
        rId : component.get('v.recordId')
    }
});
action1.fire();

I don't know why this action is 'undefined'. This code work in other components.

Can you give me an advise?

thanks
Peter
Khan AnasKhan Anas (Salesforce Developers) 
Hi Peter,

Greetings to you!


If you are previewing through dev console force events are available only inside a one.app container. Therefore launch your Component in LEX via app builder or lightning quick-action or drag to the detail page. As per Salesforce doc:

This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce app, and Lightning communities.

Also, starting in API version 43.0, the force:navigateToComponent event is deprecated. Salesforce recommends implementing the lightning:isUrlAddressable interface on your target component and navigating to the component using lightning:navigation component with the standard__component page type instead. 

https://www.salesforce.com/video/2646474/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Naveen KNNaveen KN
I think you need to replace action1 with action. try and let me know if that works.