1

Consider the following controller which builds a list of account case wrappers:

public with sharing class CasesForAccount_COM {

@AuraEnabled 
public List<caseCatWrapper> caseCatWraps {get;set;}


@AuraEnabled
public static List<caseCatWrapper> CaseCatWrapsAura (String acctId) {
    Case[] cases = retrieveCasesForAccount(acctId);
    return buildCatWrapper(cases);
}

public static Case[] retrieveCasesForAccount(Id aId) {
        return [SELECT Subject, CreatedDate, ClosedDate, Status, IsEscalated, Type
                        , CaseNumber, Support_Category__c, isClosed 
                        FROM Case
                        WHERE AccountId = : aId
                        AND CreatedDate = LAST_N_DAYS:730
                        LIMIT 1000
        ];
}

 public static List<caseCatWrapper> buildCatWrapper (Case[] cases){
    List<Case> cds = new List<Case>{};
    List<caseCatWrapper> cats = new List<caseCatWrapper>();
    Map<String,List<Case>> caseCatMap = new Map<String,List<Case>>{};
    for (Case obj : cases){
        case cd = obj.clone();
        if (obj.Support_Category__c == null 
            || obj.Support_Category__c.contains('xsi:nil=true')) {
            cd.Support_Category__c = 'Uncategorized';
        }
        cds.add(cd);
    }
    integer i = 0;
    for (case cd : cds){
        List<case> cdl = new List<case>();
        if (caseCatMap.containskey(cd.Support_Category__c)) {
            cdl = caseCatMap.get(cd.Support_Category__c);
        }
        cdl.add(cd);
        caseCatMap.put(cd.Support_Category__c,cdl);
        i++;
    }
    for (List<case> cm : caseCatMap.values()) {
        decimal s = decimal.valueOf(cm.size()).divide(i,4,System.RoundingMode.UP) * 100;
        caseCatWrapper catWrap = new caseCatWrapper(cm[0].Support_Category__c,s.intValue(),cm);
        cats.add(catWrap);
    }
    cats.sort();
    return cats;
}

public class caseCatWrapper implements Comparable {
    @AuraEnabled
    public string caseCategory {get;set;}
    @AuraEnabled
    public integer percent {get;set;}
    @AuraEnabled
    public List<Case> cases {get;set;}

    public caseCatWrapper (string c, integer i, List<Case> cs) {
        this.caseCategory = c;
        this.percent = i;
        this.cases = cs;
    }

    public Integer compareTo(Object compareTo) 
    {
        caseCatWrapper cw = (caseCatWrapper) compareTo;
        if (percent == cw.percent) return 0;
        if (percent < cw.percent) return 1;
        return -1;        
    }
}

and the part of the lightning component which displays iterates over the case list for each wrapper:

                  <table id="{!'collapseCaseList' + i}" 
                         class="slds-table slds-max-medium-table--stacked-horizontal slds-table--striped table"
                         style="width:100%;">
                      <tr>
                          <th>Case #</th>
                          <th>Subject</th>
                          <th>Date Opened</th>
                          <th>Date Closed</th>
                      </tr>
                      <aura:iteration items="{!cl.cases}" var="case">
                          <tr>
                              <td><ui:outputText value="{!case.CaseNumber}"/></td>
                              <td><ui:outputText value="{!case.Subject}"/></td>
                              <td><ui:outputDate value="{!case.CreatedDate}" format="yyyy-MM-dd"/></td>
                              <td><ui:outputDate value="{!case.ClosedDate}" format="yyyy-MM-dd"/></td>
                          </tr>
                      </aura:iteration>
                  </table>

Nothing fancy in the component controller/helper.

Problem: when the list displays, the Case Number and Date Created fields don't display.

Case #   Subject   Date Opened   Date Closed
         case 1
         case 2                  2016-01-15 

When I run a similar VF page/component, I am able to see the field values, so I don't think it's an FLS issue.

What am I missing here?

1 Answer 1

0

I don't see any problem with it. I tried it in my dev org, it worked correctly. You can give it a try by replacing ui:outputText with ui:outputNumber and ui:outputDate with ui:outputDateTime (for CreatedDate).

Thanks, Lochana

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .