I am getting the error while i am iterating the wrapper list in aura method. It is throwing exception System.unexpected exception.`I am getting the error while i am iterating the wrapper list in aura method. It is throwing exception System.unexpected exception.

Apex: CLass

@AuraEnabled
Public static List<wrapperClass> searchForDuplicates(List<wrapperClass> wrapperList){
    Set<String> searchset = new Set<String>();
    List<wrapperClass> dupList = new List<wrapperClass>();
    for(wrapperClass wc :wrapperList){
        if(wc.isSelected == true){
             System.debug('Test3'+wrapperList);
            searchset.add(wc.a.BillingCity +'#');
            searchset.add(wc.a.BillingPostalCode +'#');
            searchset.add(wc.a.BillingCountry +'#');
            searchset.add(wc.a.BillingState +'#');
            searchset.add(wc.a.BillingStreet +'#');
        }
    }
   for (wrapperClass w : wrapperList){
        if(w.isSelected == true && !searchset.contains(w.a.BillingCity) && !searchset.contains(w.a.BillingPostalCode) && !searchset.contains(w.a.BillingCountry) &&
           !searchset.contains(w.a.BillingState) && !searchset.contains(w.a.BillingStreet)){
               dupList.add(w);
          }
    }

    return wrapperList;      
}`

Javascript Controller:

onRowSelect: function (component, event, helper) {

var action = component.get("c.searchForDuplicates");
action.setParams({
    wrapperList: component.get("v.currentList")
});
alert(JSON.stringify(component.get("v.currentList")));
action.setCallback(this, function (response) {
    var state = response.getState();

    if (state == "SUCCESS") {
        var evt = $A.get("e.force:navigateToComponent");

        evt.setParams({
            componentDef: "c:TestDup",
            componentAttributes: {
                duplicatesInAcc: response.getReturnValue()
            }
        });
        evt.fire();

    } else {
        var errors = response.getError();
        alert('errors==' + JSON.stringify(errors));
        if (errors) {
            if (errors[0] && errors[0].message) {
                console.log("Error message: " + errors[0].message);
            }
        } else {
            console.log("Unknown error");
        }
    }

});
$A.enqueueAction(action);
},
  • System.unexpected exception – Anuradha Nov 30 at 11:18
  • 1
    any extra string or detail? Line number? something more verbose? – Pranay Jaiswal Nov 30 at 11:19
  • FATAL_ERROR System.UnexpectedException: Salesforce System Error: 1848583798-31248 (856768494) (856768494) – Anuradha Nov 30 at 11:21
  • Can you add a null check to see wrapperList is not null in APex? and also can you debug wrapperList to see if there is a value in it? – Pranay Jaiswal Nov 30 at 11:25
  • 1
    I apologize for saying this but if the above code is complete, it makes no sense to me. You are passing wrapperlist to searchForDuplicates and then returning it back again without any transformation. Are you supposed to return duplist or wrapperlist? – manjit5190 Nov 30 at 18:27

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.