0
I am trying to filter a javascript array (json array) with the string array, and set it back in itself.
I am using this code`
var statusFilters = component.get("v.statusFilters");
console.log('statusFilters--->'+statusFilters);
var allRecords = JSON.stringify(component.get("v.empWrapperList"));
console.log('allRecords--->'+allRecords);
var filteredRecords = allRecords.filter(rec => rec.Status__c == statusFilters);
console.log(filteredRecords);
component.set("v.empWrapperList",filteredRecords);`
Here statusFilter is a string Array and allRecords is a json array.
Here are the logs from console.
statusFilters--->Paid ClaimsDemo.js:119 allRecords--->[{"Id":"a1V2x000001K29pEAC","Name":"CL-0000004","Member__c":"0032x000004bgAkAAI","Date_of_Service__c":"2020-06-25","Provider__c":"a112x000003VXGEAA4","Status__c":"Void"},{"Id":"a1V2x000001K14OEAS","Name":"CL-0000003","Member__c":"0032x000004bgAkAAI","Billed__c":22,"Date_of_Service__c":"2015-09-15","Provider__c":"a112x000003VXGEAA4","Status__c":"Denied"},{"Id":"a1V2x000001K14JEAS","Name":"CL-0000002","Member__c":"0032x000004bgAkAAI","Billed__c":22,"Date_of_Service__c":"2019-10-16","Provider__c":"a112x000003VXGEAA4","Status__c":"Rejected"},{"Id":"a1V2x000001K14EEAS","Name":"CL-0000001","Member__c":"0032x000004bgAkAAI","Billed__c":22,"Date_of_Service__c":"2020-06-04","Provider__c":"a112x000003VXGEAA4","Status__c":"Paid"}]
Actually it is unable to execute this line var filteredRecords = allRecords.filter(rec => rec.Status__c == statusFilters);
Can you please help.