You need to sign in to do that
Don't have an account?
Gateway Bikes Group4
<!-------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();
}
})
when I'm trying to call application event then I'm getting below error
<!-------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();
}
})
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
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
I have tried to access this functionality on my Andriod device with Saleforce mobile app.But still not working.
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