I have a below lightning component
Please ignore the commented lines
<aura:attribute name="serverResponse" type="ReportsController.COABReportLineItem[]" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__body">
<h2>
<a class="slds-card__header-link slds-truncate" title="[object Object]">
<span class="slds-text-heading_small">Report Details</span>
</a>
</h2>
</div>
</header>
</div>
<div class="slds-card__body slds-card__body_inner">
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<thead>
<tr class="slds-text-title_caps">
<th scope="col">
<div class="slds-truncate" title="Full Name">Full Name</div>
</th>
<!-- <th scope="col">
<div class="slds-truncate" title="COAB Last Modified Date">COAB Last Modified Date</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Note Subject">Note Subject</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Note Description">Note Description</div>
</th> -->
<th scope="col">
<div class="slds-truncate" title="Task Subject">Task Subject</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Task Description">Task Description</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Task Due Date">Task Due Date</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Call Center Agent">Call Center Agent</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!serverResponse}" var="detail">
<tr>
<td data-label="Full Name">
<div class="slds-truncate" title="{!detail.ClientName}">{!detail.ClientName}</div>
</td>
<!--<td data-label="COAB Last Modified Date">
<div class="slds-truncate" title="{!detail.Coloum}">value</div>
</td>
<td data-label="Note Subject">
<div class="slds-truncate" title="{!detail.Coloum}">value</div>
</td>
<td data-label="Note Description">
<div class="slds-truncate" title="{!detail.Notecription}">{!detail.NoteDescription}</div>
</td> -->
<td data-label="Task Subject">
<div class="slds-truncate" title="{!detail.Subject}">{!detail.TaskSubject}</div>
</td>
<td data-label="Task Description">
<div class="slds-truncate" title="{!detail.TaskDescription}">{!detail.TaskDescription}</div>
</td>
<td data-label="Task TaskDueDate">
<div class="slds-truncate" title="{!detail.TaskDueDate}">{!detail.TaskDueDate}</div>
</td>
<td data-label="Call Center Agent">
<div class="slds-truncate" title="{!detail.CallCentreAgent}">{!detail.CallCentreAgent}</div>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</article>
Controller:
({
doInit : function(component, event, helper)
{
helper.loadInitData(component, event, helper);
},
})
Helper:
({
loadInitData : function(component, event, helper)
{
var action = component.get("c.GetCOABReportData");
if (action == null)
return;
action.setParams({ OwnerId : null });
action.setCallback(this, function(response)
{
var state = response.getState();
if(state === "SUCCESS")
{
var result = response.getReturnValue();
component.set("v.serverResponse", result);
console.log(component.get("v.serverResponse"));
}
else if(state === "INCOMPLETE")
{
// do something
}
else if(state === "ERROR")
{
var errors = response.getError();
if (errors)
{
if (errors[0] && errors[0].message)
{
console.log("Error message: " + errors[0].message);
}
}
else
{
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
},
})
apex controller
public class ReportsController {
@AuraEnabled
public static List<COABReportLineItem> GetCOABReportData(string OwnerId)
{
if (OwnerId == null)
{
OwnerId=UserInfo.getUserId();
}
List<COABReportLineItem> reportData=new List<COABReportLineItem>();
User COABAgent=[Select AssignedCOABAgent__C from User where Id=:OwnerId Limit 1];
if (COABAgent == null)
{
return reportData;
}
else
{
List<Task> coabTasks = new List<Task>();
coabTasks = [SELECT Id,Who.Name, Subject,Description, ActivityDate, Status, OwnerId, CreatedBy.Name, CreatedDate,LastModifiedById FROM Task where CreatedById=:COABAgent.AssignedCOABAgent__C And OwnerId=:OwnerId];
if (coabTasks != null)
{
COABReportLineItem coabReportLineItem;
for(Task coabTask:coabTasks)
{
coabReportLineItem = new COABReportLineItem();
coabReportLineItem.ClientName = UserInfo.getUserName();
COABReportLineItem.TaskSubject = coabTask.Subject;
COABReportLineItem.TaskDescription = coabTask.Description;
COABReportLineItem.TaskDueDate = coabTask.ActivityDate;
COABReportLineItem.CallCentreAgent = coabTask.CreatedBy.Name;
reportData.add(COABReportLineItem);
}
}
return reportData;
}
}
}
and
public class COABReportLineItem {
@AuraEnabled
public string ClientName {get;set;}
@AuraEnabled
public DateTime COABLastModifiedDate {get;set;}
@AuraEnabled
public string NoteSubject {get;set;}
@AuraEnabled
public string NoteDescription {get;set;}
@AuraEnabled
public string TaskSubject {get;set;}
@AuraEnabled
public string TaskDescription {get;set;}
@AuraEnabled
public DateTime TaskDueDate {get;set;}
@AuraEnabled
public string CallCentreAgent {get;set;}
}
In console log I am gettign 2 result snip is attached
But still aura Iteration is not returning any rows on the page, can someone please suggest?