0

My Component code :

<aura:attribute type="List" name="filterCriteriaList"/>

My Componenet Helper.js code :

getOperator : function(component, event, helper){
        var fieldName = component.find("fieldSelect").get("v.value");
        var index = component.find("hiddenIndex").get("v.value");
        console.log(' >>>>> ' + JSON.stringify(component.get('v.filterCriteriaList')));
        var action = component.get("c.fetchOperators");
        action.setParams({ "index" : index, "fieldName" : fieldName, "filterCriteriaItemJson" : JSON.stringify(component.get('v.filterCriteriaList'))});

        action.setCallback(this, function(response) {

My Apex controller code:

@auraEnabled
    public static void fetchOperators(Integer currentIndex, String fieldName, String filterCriteriaItemJson){
        //System.debug('***filterCriteriaItemJson='+filterCriteriaItemJson);
        List<FilterCriteria> filterCriteriaItems = (List<FilterCriteria>)JSON.deserializeStrict(filterCriteriaItemJson,List<FilterCriteria>.class);
        for(FilterCriteria f : filterCriteriaItems){ 
            if (f.index == currentIndex && f.fieldName.equalsIgnoreCase(fieldName)){                   
                f.operatorsList  = Utility.getOperator(f.mapFieldTypes.get(fieldName));
            }
        }        
    }

For your referrence I have FilterCriteria as wrapper class and I am creating List<FilterCriteria> and sending it from component to apex controller to manipulate further values in wrapper.

When i call fetchOperators from helper file then it throws error saying

    FATAL_ERROR System.UnexpectedException: Salesforce System Error: 1803375914-142009 (577092351) (577092351)
FATAL_ERROR Class.System.JSON.deserializeStrict: line 19, column 1
 FATAL_ERROR Class.PaginationFilterController.fetchOperators: line 61, column 1

I tried using $A.util.json.encode in helper fiel to encode wrapper list but no luck. Need help on this.

Thanks in advance

Below is the WrapperClass

@auraEnabled
public string objectname { get; set; }
@auraEnabled
public string fieldname { get; set; }
@auraEnabled
public string fieldvalue { get; set; }
@auraEnabled
public string fieldtype { get; set; }
@auraEnabled
public string operator { get; set; }
@auraEnabled
public String condition {get;set;}
@auraEnabled
public boolean lookupicon { get; set; }
@auraEnabled
public integer index { get; set; }  
@auraEnabled
public sObject sObjectToBind {get;set;}  
@auraEnabled
public List<SelectOption> fieldList { get; set; } 
@auraEnabled
public List<SelectOption> operatorsList { get; set; } 
@auraEnabled
public map<String,String> mapFieldTypes { get; set; }
public String Query ='';


public FilterCriteria(integer i){
    objectname  = '';
    fieldname  = '';
    fieldvalue  = '';
    fieldtype  = '';
    operator  = '';
    condition = 'and';
    index = i;    
    fieldList = new List<SelectOption>{new SelectOption('','--None--')}; 
    operatorsList  = new List<SelectOption>{new SelectOption('','--None--')}; 
    mapFieldTypes  = new  map<String,String>();
}   

public List<SelectOption> getConditionList(){
    List<SelectOption> conditionList = new List<SelectOption>();
    conditionList.add(new SelectOption('or','OR'));
    conditionList.add(new SelectOption('and','AND'));
    return conditionList;
}

private string getSelectedValue(){
    if (sObjectToBind == null || fieldname == null)
        return null;
    else if (sObjectToBind != null && fieldname != null && (sObjectToBind.get(fieldname) == null 
                            || sObjectToBind.get(fieldname) == ''))
        return null;                                
    else
        return String.valueOf(sObjectToBind.get(fieldname));
}   

public boolean getisProcessAble(){
    if (fieldname != '' && operator != '' && getSelectedValue() != null)
        return true;
    else
        return false;          
}

Below is the JSON

[{"condition":"and","fieldList":[{"disabled":false,"escapeItem":false,"label":"--None--","value":""},{"disabled":false,"escapeItem":false,"label":"--None--","value":""},{"disabled":false,"escapeItem":false,"label":"Account ID","value":"accountid"},{"disabled":false,"escapeItem":false,"label":"Assistant's Name","value":"assistantname"},{"disabled":false,"escapeItem":false,"label":"Asst. Phone","value":"assistantphone"},{"disabled":false,"escapeItem":false,"label":"Birthdate","value":"birthdate"},{"disabled":false,"escapeItem":false,"label":"Business Fax","value":"fax"},{"disabled":false,"escapeItem":false,"label":"Business Phone","value":"phone"},{"disabled":false,"escapeItem":false,"label":"Clean Status","value":"cleanstatus"},{"disabled":false,"escapeItem":false,"label":"Contact ID","value":"id"},{"disabled":false,"escapeItem":false,"label":"Created By ID","value":"createdbyid"},{"disabled":false,"escapeItem":false,"label":"Created Date","value":"createddate"},{"disabled":false,"escapeItem":false,"label":"Data.com Key","value":"jigsaw"},{"disabled":false,"escapeItem":false,"label":"Deleted","value":"isdeleted"},{"disabled":false,"escapeItem":false,"label":"Department","value":"department"},{"disabled":false,"escapeItem":false,"label":"Do Not Call","value":"donotcall"},{"disabled":false,"escapeItem":false,"label":"Email","value":"email"},{"disabled":false,"escapeItem":false,"label":"Email Bounced Date","value":"emailbounceddate"},{"disabled":false,"escapeItem":false,"label":"Email Bounced Reason","value":"emailbouncedreason"},{"disabled":false,"escapeItem":false,"label":"Email Opt Out","value":"hasoptedoutofemail"},{"disabled":false,"escapeItem":false,"label":"Fax Opt Out","value":"hasoptedoutoffax"},{"disabled":false,"escapeItem":false,"label":"First Name","value":"firstname"},{"disabled":false,"escapeItem":false,"label":"Full Name","value":"name"},{"disabled":false,"escapeItem":false,"label":"Home Phone","value":"homephone"},{"disabled":false,"escapeItem":false,"label":"Is Email Bounced","value":"isemailbounced"},{"disabled":false,"escapeItem":false,"label":"Jigsaw Contact ID","value":"jigsawcontactid"},{"disabled":false,"escapeItem":false,"label":"Languages","value":"languages__c"},{"disabled":false,"escapeItem":false,"label":"Last Activity","value":"lastactivitydate"},{"disabled":false,"escapeItem":false,"label":"Last Modified By ID","value":"lastmodifiedbyid"},{"disabled":false,"escapeItem":false,"label":"Last Modified Date","value":"lastmodifieddate"},{"disabled":false,"escapeItem":false,"label":"Last Name","value":"lastname"},{"disabled":false,"escapeItem":false,"label":"Last Referenced Date","value":"lastreferenceddate"},{"disabled":false,"escapeItem":false,"label":"Last Stay-in-Touch Request Date","value":"lastcurequestdate"},{"disabled":false,"escapeItem":false,"label":"Last Stay-in-Touch Save Date","value":"lastcuupdatedate"},{"disabled":false,"escapeItem":false,"label":"Last Viewed Date","value":"lastvieweddate"},{"disabled":false,"escapeItem":false,"label":"Lead Source","value":"leadsource"},{"disabled":false,"escapeItem":false,"label":"Level","value":"level__c"},{"disabled":false,"escapeItem":false,"label":"Mailing Address","value":"mailingaddress"},{"disabled":false,"escapeItem":false,"label":"Mailing City","value":"mailingcity"},{"disabled":false,"escapeItem":false,"label":"Mailing Country","value":"mailingcountry"},{"disabled":false,"escapeItem":false,"label":"Mailing Geocode Accuracy","value":"mailinggeocodeaccuracy"},{"disabled":false,"escapeItem":false,"label":"Mailing Latitude","value":"mailinglatitude"},{"disabled":false,"escapeItem":false,"label":"Mailing Longitude","value":"mailinglongitude"},{"disabled":false,"escapeItem":false,"label":"Mailing State/Province","value":"mailingstate"},{"disabled":false,"escapeItem":false,"label":"Mailing Street","value":"mailingstreet"},{"disabled":false,"escapeItem":false,"label":"Mailing Zip/Postal Code","value":"mailingpostalcode"},{"disabled":false,"escapeItem":false,"label":"Master Record ID","value":"masterrecordid"},{"disabled":false,"escapeItem":false,"label":"Mobile Phone","value":"mobilephone"},{"disabled":false,"escapeItem":false,"label":"Other Address","value":"otheraddress"},{"disabled":false,"escapeItem":false,"label":"Other City","value":"othercity"},{"disabled":false,"escapeItem":false,"label":"Other Country","value":"othercountry"},{"disabled":false,"escapeItem":false,"label":"Other Geocode Accuracy","value":"othergeocodeaccuracy"},{"disabled":false,"escapeItem":false,"label":"Other Latitude","value":"otherlatitude"},{"disabled":false,"escapeItem":false,"label":"Other Longitude","value":"otherlongitude"},{"disabled":false,"escapeItem":false,"label":"Other Phone","value":"otherphone"},{"disabled":false,"escapeItem":false,"label":"Other State/Province","value":"otherstate"},{"disabled":false,"escapeItem":false,"label":"Other Street","value":"otherstreet"},{"disabled":false,"escapeItem":false,"label":"Other Zip/Postal Code","value":"otherpostalcode"},{"disabled":false,"escapeItem":false,"label":"Owner ID","value":"ownerid"},{"disabled":false,"escapeItem":false,"label":"Photo URL","value":"photourl"},{"disabled":false,"escapeItem":false,"label":"Reports To ID","value":"reportstoid"},{"disabled":false,"escapeItem":false,"label":"Salutation","value":"salutation"},{"disabled":false,"escapeItem":false,"label":"System Modstamp","value":"systemmodstamp"},{"disabled":false,"escapeItem":false,"label":"Title","value":"title"}],"fieldname":"birthdate","fieldtype":"","fieldvalue":"","index":1,"mapFieldTypes":{"id":"ID","isdeleted":"BOOLEAN","masterrecordid":"REFERENCE","accountid":"REFERENCE","lastname":"STRING","firstname":"STRING","salutation":"PICKLIST","name":"STRING","otherstreet":"TEXTAREA","othercity":"STRING","otherstate":"STRING","otherpostalcode":"STRING","othercountry":"STRING","otherlatitude":"DOUBLE","otherlongitude":"DOUBLE","othergeocodeaccuracy":"PICKLIST","otheraddress":"ADDRESS","mailingstreet":"TEXTAREA","mailingcity":"STRING","mailingstate":"STRING","mailingpostalcode":"STRING","mailingcountry":"STRING","mailinglatitude":"DOUBLE","mailinglongitude":"DOUBLE","mailinggeocodeaccuracy":"PICKLIST","mailingaddress":"ADDRESS","phone":"PHONE","fax":"PHONE","mobilephone":"PHONE","homephone":"PHONE","otherphone":"PHONE","assistantphone":"PHONE","reportstoid":"REFERENCE","email":"EMAIL","title":"STRING","department":"STRING","assistantname":"STRING","leadsource":"PICKLIST","birthdate":"DATE","ownerid":"REFERENCE","hasoptedoutofemail":"BOOLEAN","hasoptedoutoffax":"BOOLEAN","donotcall":"BOOLEAN","createddate":"DATETIME","createdbyid":"REFERENCE","lastmodifieddate":"DATETIME","lastmodifiedbyid":"REFERENCE","systemmodstamp":"DATETIME","lastactivitydate":"DATE","lastcurequestdate":"DATETIME","lastcuupdatedate":"DATETIME","lastvieweddate":"DATETIME","lastreferenceddate":"DATETIME","emailbouncedreason":"STRING","emailbounceddate":"DATETIME","isemailbounced":"BOOLEAN","photourl":"URL","jigsaw":"STRING","jigsawcontactid":"STRING","cleanstatus":"PICKLIST","level__c":"PICKLIST","languages__c":"STRING"},"objectname":"","operator":"","operatorsList":[{"disabled":false,"escapeItem":false,"label":"--None--","value":""}],"sObjectToBind":{}}]
7
  • Try using deserialize instead of deserializeStrict and see if it works fine. If it does then your JSON has additional attributes
    – manjit5190
    Feb 21, 2018 at 11:29
  • I tried using deserialize but still getting the same error. Feb 21, 2018 at 11:51
  • Maybe sharing a sample filterCriteriaList JSON and the structure of your wrapper class would help. Feb 21, 2018 at 12:19
  • Sure ... let me send you the JSON and wrapper class Feb 21, 2018 at 14:41
  • 1
    My suspicion would be with the sObjectToBind attribute - you're passing an empty object there: {} and perhaps JSON parser in Apex cannot make an SObject out of that. I would suggest trying with a null instead. And since the object structure is quite complex - maybe try reducing your JSON - i.e. removing some parts of it and see at which point it will parse successfully. Feb 22, 2018 at 10:25

0

You must log in to answer this question.

Browse other questions tagged .