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
Gateway Bikes Group4Gateway Bikes Group4 

when I'm trying to call application event then I'm getting below error

User-added image

User-added image
<!-------Lightning Component:Opencase.cmp----->

<aura:component controller="OpenCasesApexController" implements="force:appHostable">
<aura:attribute name="cases" type="Case[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:iteration items="{!v.cases}" var="case">
    <c:CaseList case="{!case}"/>
    </aura:iteration>
  </aura:component>
  
  <!--Lightning App:OpenCasesApp.app-->
<aura:application >
    <c:OpenCases/>
</aura:application>

<!---OpenCasesController.js->
({
doInit:function(cmp,event,helper){
       var action=cmp.get("c.getCaseDB");
       console.log('calling doInit');
       
       action.setCallback(this,function(response){
        var state=response.getState();
        
        if(cmp.isValid()  &&  state === "SUCCESS"){
          console.log('getting cases');
        
          cmp.set("v.cases",response.getReturnValue());
          }
});
     $A.enqueueAction(action);
}
  
   })
   
   //Apex Controller
    public with sharing class OpenCasesApexController {
 @AuraEnabled
    public static List <Case> getCaseDB(){
     String [] caseFields =new String[]{'Id','OwnerId','Type','Status','Priority',
                                     'IsClosed','Reason','Origin'};
        
         //Create a Map for all the Case object
          Map<String,Schema.SobjectField> caseMap = 
           Schema.SobjectType.Case.fields.getMap();
         
           for(String field:caseFields){
                if(!caseMap.get(field).getDescribe().isAccessible()){
                 System.debug('This field was not accessible:' +caseMap.get(field));
                 return null;
                     }
                  }   
    
         return [SELECT  Id
                      FROM Case 
                      where IsClosed=false
                      AND OwnerId =:UserInfo.getUserId() limit 5];
  }
}
<!--Nesting the Component:CaseList.cmp -->
<aura:component >
    <aura:attribute name="case" type="Case"/>
       <div onclick="{!c.goToRecord}">
        <force:recordview recordId="{!v.case.Id}" type="MINI"/>
        </div>
</aura:component>

<!--CaseListController.js-->
({
      goToRecord:function(cmp,event,helper){
    //Declaration of variable
    var sObjectEvent=$A.get("e.force:navigateToSobject");
        sObjectEvent.setParams({    "recordId":cmp.get("v.case.Id"),
                                "slideDevName":'detail'
        }) 
            sObjectEvent.fire();
        
        }
})

   
   
   
Best Answer chosen by Gateway Bikes Group4
Maharajan CMaharajan C
Hi,

The Issue is due to case-sensitive here in navigateToSobject  --> navigateToSObject  letter O should be in Caps.
 
goToRecord:function(cmp,event,helper){
        var sObjectEvent=$A.get("e.force:navigateToSObject");
        sObjectEvent.setParams({    
            "recordId":cmp.get("v.case.Id"),
            "slideDevName":"detail"
                               });
        sObjectEvent.fire();
    }

Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Maharajan.C

All Answers

Raj VakatiRaj Vakati
How are you using this apps ??


force:navigateToSobject is  It’s supported in Lightning Experience, the Salesforce app, and Lightning communities.

If you are using it from the .app it wnt work ..so add the component to lightning experience page and try
Gateway Bikes Group4Gateway Bikes Group4
Hi Raj,

I have tried to access this functionality on my Andriod device with Saleforce mobile app.But still not working. 
Raj VakatiRaj Vakati
try sforce.one api 
Maharajan CMaharajan C
Hi,

The Issue is due to case-sensitive here in navigateToSobject  --> navigateToSObject  letter O should be in Caps.
 
goToRecord:function(cmp,event,helper){
        var sObjectEvent=$A.get("e.force:navigateToSObject");
        sObjectEvent.setParams({    
            "recordId":cmp.get("v.case.Id"),
            "slideDevName":"detail"
                               });
        sObjectEvent.fire();
    }

Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Maharajan.C
This was selected as the best answer
Raj VakatiRaj Vakati
Correct .. its should be caps 
 
({
      goToRecord:function(cmp,event,helper){
    //Declaration of variable
    var sObjectEvent=$A.get("e.force:navigateToSObject");
        sObjectEvent.setParams({    "recordId":cmp.get("v.case.Id"),
                                "slideDevName":"detail"
        }) 
            sObjectEvent.fire();
        
        }
})