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
Abi V 4Abi V 4 

DoInt in Controller returns null data +Lightining Components

I have the method in doInit which will retrun the data if satisfying few conditions.
There is a chance like data can be return null and in this case i am facing the error that
"Error in $A.getCallback() [a.getReturnValue(...) is null]".Please let me know how to solve this error and it is very urjency.
sfdcMonkey.comsfdcMonkey.com
hi Abi V 4
can your Please share your code onces
Thanks
Abi V 4Abi V 4
Hi 
fine the below code
//helper............
  wrapperMultiValue: function(component, event, helper){
        var accrecid=component.get("v.AccountId");
        //alert('accountid>>>>'+accrecid);
        var action = component.get("c.NewGetPicklistCompetetorsValue"); 
         action.setParams({ 
            accId : accrecid     
        }); 
        var rightarray=[];  
        var leftarray=[]; 
        action.setCallback(this, function(a) {
                       for(var i=0;i<a.getReturnValue().length;i++){
                if(a.getReturnValue()[i].Selecetd){
                    rightarray.push({index: i ,value: a.getReturnValue()[i].ListValue}); 
                }
                else{
                    leftarray.push({index: i ,value: a.getReturnValue()[i].ListValue});
                }
            } 
         
            component.set("v.received",leftarray);
            component.set("v.receivedSelect",rightarray);
        });
        $A.enqueueAction(action); 
    },
=====================
Client Controller
doInit : function(component, event, helper) {
        helper.wrapperMultiValue(component, event, helper); 
           
    }, 
Abi V 4Abi V 4
wrapperMultiValue retruns null on load the page so i am getting null exception.
sfdcMonkey.comsfdcMonkey.com
can you also sahre apex Class onces?
 
Abi V 4Abi V 4
 @AuraEnabled  
    public static List<WrapperMultipleSelectTopline> NewGetPicklistCompetetorsValue(String accId){
    //Account accname=[select id,name,Master_Customer_Number__c,(select id,MCN__C FROM Master_Customer_Number__r) from Account where Id=:accId];
    Account accname=[Select id,name,Master_Customer_Number__c from Account where Id =:accId];    
    //select id,name,Account_Name__c,MCN__c,ATM_Client_SW__c,HW_Owned_By_Customer__c,iServices__c,Channel_Management__c,ATM_SS_Fraud_SW__c,Check_Processing__c,Cx_Marketing__c,Remote_Distributed_Capture__c from Majors_Product_Matrix__c where MCN__c =:acc.Master_Customer_Number__c];    
        Map<String,Boolean> KeyOpportunityMap=new Map<String,Boolean>();
        String str1=[select id,name,Account_Name__c,MCN__c,New_Competetors__c ,ATM_Client_SW__c,iServices__c,Channel_Management__c,ATM_SS_Fraud_SW__c,Check_Processing__c,Cx_Marketing__c,Remote_Distributed_Capture__c from Majors_Product_Matrix__c where MCN__c =:accname.Master_Customer_Number__c].New_Competetors__c ;
        String str2=[Select Id, Competetors__c From ToplineCompetetors__c limit 1].Competetors__c;  
        if(String.isNotBlank(str1) && str1.length()>1){  
                for(String str : str1.split(';')){
                  KeyOpportunityMap.put(str, true); 
                } 
        }
        if(String.isNotBlank(str2) && str2.length()>1){
            for(String str : str2.split(';')){
                        if(!KeyOpportunityMap.containsKey(str))
                        KeyOpportunityMap.put(str, false); 
                } 
        }
         
        List<WrapperMultipleSelectTopline>  WrapperList=new List<WrapperMultipleSelectTopline>();
        for(String Mapstrvalue: KeyOpportunityMap.KeySet())
        {
            if(KeyOpportunityMap.containsKey(Mapstrvalue))
            {
                WrapperList.add(new WrapperMultipleSelectTopline(Mapstrvalue,KeyOpportunityMap.get(Mapstrvalue)));
            }
        }  
         
         if(WrapperList.size()>0){
           return WrapperList; 
        }
        
        else{
        return null;
        }