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
AntonPavlovAntonPavlov 

help to find mistake

I need display data as a list receiving via class FindDuplicateCase to aura component. But I have empty page, although the class returns values when debugging 
Class Apex
public class FindDuplicateCase {
@AuraEnabled
    public static List<Case> getCaseListDuplicate(){
        List<Case> caseFields =[SELECT Id,CaseNumber,Origin,Subject,SuppliedEmail,Status,Reason,OwnerId FROM Case WHERE Status!='Closed'];
        List<Case> duplicateCaseList = new List<Case>();
        for(Case case1:caseFields){
           for(Case case2:caseFields){
               if(case1.Subject==case2.Subject && case1.SuppliedEmail==case2.SuppliedEmail && case1.Reason==case2.Reason){
                    duplicateCaseList.add(case1);
               }
            }
        }
        return duplicateCaseList; 
    }
}
Aura component 
<aura:component implements="force:lightningQuickAction" controller="FindDuplicateCase" access="global">
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" />
    <aura:attribute name="duplicateCaseList" type="List" />
        <aura:iteration items="{!v.duplicateCaseList}" var="item">
                <ul>
                <li>Case Number{!item.CaseNumber}</li>
            </ul>
           </aura:iteration>     
</aura:component>
Javascript 
({
    doInit: function(component, event, helper) {
        const list = component.get('c.getCaseListDuplicate');
        component.set("v.duplicateCaseList",list);
        $A.enqueueAction(list);
    }
})
Best Answer chosen by AntonPavlov
Sachin HoodaSachin Hooda
You're missing out some pieces of the code. To make a server call & store the response. You need to set a callback. So whenever the server replies to your request, the code in the callback would be executed, the returned response in your case. To add a callback to the server-side call you need to change your like, 
 
const list = component.get('c.getCaseListDuplicate');
 action.setCallback(this, function(response){
           if(response.getState() === 'SUCCESS'){
                 component.set("v.duplicateCaseList",list);
             } else {
                 console.log('::Some error occurred::');
              }
});
$A.enqueueAction(list);

Since server response isn't instant. This way whenever the server responds to your request. the code within action.setCallback(this, function(response){ .....}); will be executed.