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
SFDC pvSFDC pv 

When i click on search i need to make a callout and listout the response as line items in the UI. I'm not getting proper response when i click on the Search button(see the below log).Please help me

intosearchHelper
Test_ModalSearchComponent.js:16 actionSecureAction: [object Object]{ key: {"namespace":"c"} }
Test_ModalSearchComponent.js:23 ####returnvalueERROR
Test_ModalSearchComponent.js:25 ####parentIdnull
Test_ModalSearchComponent.js:14 intosearchHelper
Test_ModalSearchComponent.js:16 actionSecureAction: [object Object]{ key: {"namespace":"c"} }
Test_ModalSearchComponent.js:23 ####returnvalueERROR
Test_ModalSearchComponent.js:25 ####parentIdnull

Test_ModalSearchComponent:-
<aura:component controller ="Test_xxController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
                      <div style="display:inline-block;margin-right:10px" onclick="{!c.Search}">
                        <lightning:icon iconName="utility:search" size="small" >
                           </lightning:icon>

Controller:-

({
        Search : function(component, event, helper) {
        var action = component.get("c.invokeWebService");
        console.log('action');
        action.setParams({
            "CaseId" : component.get("v.recordId")
        
        });
        action.setCallback(this, function(response) {
        var state = response.getState();
        console.log('####returnvalue'+state);
        var parentId = component.get('v.recordId');
        console.log('####parentId'+response.getReturnValue());
        
        if (state == "SUCCESS") {
                var output = response.getReturnValue();
                component.set("v.response", output);
                console.log(output);
        }   
   });
             $A.enqueueAction(action);
},
})

Apex controller:-

global class Test_xxController {
    
    @AuraEnabled
    @future(callout=true)
    Public static void invokeWebService(String CaseId) {
        
        Map <String,xx_Information__c > FFMap = new Map <String,xx_Information__c> ();   
        
        Map<String, Integer> monthAndMonthNumberMap = new Map<String, Integer>();
        monthAndMonthNumberMap.put('Jan', 1);
        monthAndMonthNumberMap.put('Feb', 2);
        monthAndMonthNumberMap.put('Mar', 3);
        monthAndMonthNumberMap.put('Apr', 4);
        monthAndMonthNumberMap.put('May', 5);
        monthAndMonthNumberMap.put('Jun', 6);
        monthAndMonthNumberMap.put('Jul', 7);
        monthAndMonthNumberMap.put('Aug', 8);
        monthAndMonthNumberMap.put('Sep', 9);
        monthAndMonthNumberMap.put('Oct', 10);
        monthAndMonthNumberMap.put('Nov', 11);
        monthAndMonthNumberMap.put('Dec', 12);
        
        List<Case> Caslist= [SELECT Id,AccountID,xx_Number__c FROM Case  WHERE ID =:CaseId ];
        List<xx_Information__c> listofFF = new List<xx_Information__c>();
        List<xx_Information__c> DFFlist= new list<xx_Information__c>([SELECT xx_Number__c FROM xx_Information__c WHERE Case__c =:CaseId ]);
        
        Set<String> loffinstr = new Set<String>();
        Set<String> Dloffinstr = new Set<String>();
        Set<String> Nloffinstr = new Set<String>();
        Boolean isDuplicate;
        for(xx_Information__c finfo : DFFlist ){
            loffinstr.add(finfo.xx_Number__c);
            Dloffinstr.add(finfo.xx_Number__c);
            
        }
        Case Cas= [SELECT Id,AccountID,xx_Number__c FROM Case  WHERE ID =:CaseId ];
        system.debug('***Case-FF***'+Cas);
 
            for (String num : Cas.xx_Number__c.split(',') )
            {
                system.debug('Numbers'+num);
                if (Nloffinstr.Contains(num)) {
                  //  Isduplicate = true;                
                }
                else {
                    Nloffinstr.add(num);
                }
                
                if(num!='' && !loffinstr.contains(num)){
                    system.debug('insideloop'+num);
                    loffinstr.add(num);
                    xx_ResponseWrapper xxResponse = xx_InvokeAPI.invokexxAPI(num);                 
                    system.debug('$$$xxResponse$$$'+xxResponse);              
                    if(xxResponse != Null){
                        xx_Information__c ff = new xx_Information__c();
                        ff.Name = xxResponse.firstName+' '+xxResponse.lastName;
                        ff.xx_Email__c = xxResponse.email;
                        ff.xx_Number__c = num;
                        ff.Case__c = Cas.ID;
                        ff.Account__c = Cas.AccountId;
                        
                        for(xx_xxResponseWrapper.programDetails  program: xxResponse.programDetails){
                            if(program.ffExpireDate!=null){
                                String myDateStr = program.ffExpireDate;
                                System.debug('$$$ mydateStr: '+ myDateStr);
                                List<String> myDateList = myDateStr.split('-');
                                Integer yearVal = Integer.valueOf(myDateList.get(2));
                                Integer monthVal = monthAndMonthNumberMap.get(myDateList.get(1));
                                Integer dayVal = Integer.valueOf(myDateList.get(0));
                                date mydate = date.newinstance(yearVal,monthVal,dayVal);
                                ff.Freq_Flyer_Expiry_Date__c = mydate;
                                ff.Current_Tier__c = program.tierName;
                            }                         
                        }
                        ff.Request_Type__c = '';
                        ff.Upgrade_Tier_Requested__c = '';                               
                        listofFF.add(ff);
                    }
                }
            }            

        if(listofFF.size()>0) {
            insert listofFF;              
            system.debug('Insertion'+listofFF);    
        }
    }
}