I have a standard component case page, when i choose one of the case and click on it, it displays 'Case Detail' page. Once the 'Case Detail' page is loaded, i have written one lightning component, on click of that lightning component button, i need to get the logged in user information and current case number.

<aura:component controller="testController" implements="forceCommunity:availableForAllPageTypes,force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global" > 

<!-- to get email address -->
<aura:attribute name="Email" type="String"/>
<aura:handler name="init" value="{!this}" action="{!c.getEmailAddress}"/>

<!- to get the case details -->
<aura:attribute name="casesList" type="case[]" />    
<aura:handler name="init" value="{!this}" action="{!c.getCasesList}"/>
<aura:iteration items="{!v.casesList}" var="case" end="5">

The above is displaying all case details. User can have multiple case numbers. But i need only current caseNumber from caseDetail page. On button click of my lighning component, i need pass userinfo,casenumber as parameters.

Controller :

getEmailAddress: function(component, event, helper) {
    var action = component.get("c.getUserEmailAddress"); // method in the apex class
    action.setCallback(this, function(a) {
        if (a.getState() === "SUCCESS") {
            component.set("v.Email", a.getReturnValue()); // variable in the component

getCasesList : function(component, event, helper) {
    var action = component.get("c.getCasesListVal");
    action.setCallback(this, function(response) {
        if (response.getState() === "SUCCESS") {
            component.set("v.casesList" , response.getReturnValue());

Below is the apex classs

public static String getUserEmailAddress() {
    return UserInfo.getUserEmail();

public static List<Case> getCasesListVal()
List<Case> casesList = [select id, CaseNumber, Subject, CreatedDate, Status, Priority
                               from Case
                               order by CreatedDate desc
                               limit 5];
    return casesList;        
  • Use the recordId and the lightning data service
    – Eric
    Jun 11, 2017 at 4:09
  • @Eric, the Lighting Data Service is in beta and I wouldn't recommend using it if you build a small component that needs to be deployed to prod. Jun 11, 2017 at 6:45
  • Or whatever option you choose. the important part is the recordId attribute
    – Eric
    Jun 11, 2017 at 7:14
  • @Eric, is recordId and caseNumber are same? Jun 12, 2017 at 12:58


You must log in to answer this question.

Browse other questions tagged .