Sample:
var filterConditionType = "8"; var arr = { "dashboardList": [ { "uploadId":6293, "fileName":"AP_Mand_3.dbf", "fileTimeStamp":1530525054000, "total":null, "processed":null, "rejected":null, "actionRequired":null, "pending":null, "status":"R", "formatId":"8", "userTransactionList":null }, { "uploadId":9052, "fileName":"Fatca BV_07.dbf", "fileTimeStamp":1530524927000, "total":null, "processed":null, "rejected":null, "actionRequired":null, "pending":null, "status":"R", "formatId":"9", "userTransactionList":null } ] }; var filteredArray = arr.dashboardList.filter(el=>el.type==filterConditionType);
The prior code is working fine in normal javascript editors but when same code is executing in the javascript policy, it is not working.
Can anybody tell me what i have done wrong?
The Array.prototype.filter method works.
However, the ES6-style arrow functions do not. JS callouts use Trireme and Rhino 1.7.9, which allows ES5.
Try something like this:
var filteredArray = arr.dashboardList.filter(function(el){ return el.type==filterConditionType; });
ps: I don't see a .type property on the elements in your dashboardList array. Maybe just the result of a cut/paste error on your part.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |