0

How does Salesforce handle opening a lightning app from developer console (vs) creating a tab view in lightning.

I created a sample app that has a button which calls the e.force:navigateToList event on press. When I open it in lightning mode as a tab the click event works as expected and navigates me to the contact list, but the same causes an error when I open through developer console preview link.

Something has gone wrong. Error in $A.getCallback() [TypeError: Cannot read property 'setParams' of undefined] Failing descriptor: {markup://prao6308:navigateappmaincomp}. Please try again.

As per docs: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToList.htm

This event is handled by the one.app container. It’s supported in Lightning Experience and Salesforce1 only.

Does this mean the force:XXXX events will work only in Lightning only mode and cannot be tested using the preview button from dev console? (or) is there something basic that I am overlooking about lightning architecture?

**

component:

**

<aura:component implements="force:appHostable" controller="controllerforlistview">   
    <ui:button label="Go to second component" press="{!c.navigateToMyList}"/>
</aura:component>

Controller:

({
    navigateToMyList : function(component, event, helper) {
        var action = component.get("c.getListViews");
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var listviews = response.getReturnValue();
                var navEvent = $A.get("e.force:navigateToList");
                navEvent.setParams({
                    "listViewId": listviews.Id,
                    "listViewName": null,
                    "scope": "Contact"
                });
                navEvent.fire();
            }
        });
        $A.enqueueAction(action);
    }})

Ouput:

3
  • force events are handled in one/one.app container only.Look at this answer, it will help.
    – Praveen
    Oct 4, 2016 at 16:36
  • @Praveen thats kinda what I understood, why take the pain of having a preview button that does nothing then is my question
    – Rao
    Oct 4, 2016 at 16:53
  • Rao, I didn't understand what is been said in your comment regarding the preview button.
    – Praveen
    Oct 4, 2016 at 17:02

0

You must log in to answer this question.