Skip to main content

I’m trying to use Javascript to filter down a list of selected records.  The idea is that the user selects a bunch of records, and we make different updates depending on the Status of the selected record. 

The console shows me ‘records’ when I’ve selected them, but nothing in ‘filtered list.’  “Status” in the proper API name of the Status field on the Case object. 


Any ideas what might be wrong with this Javascript? 


$ = skuid.$;

var params = argumentsa0];

var models = skuid.model.map();

var Cases = models.CasesToCover;


    var records = skuid.$.map(arguments=0].list.getSelectedItems(),function(item){ 

        return item.row.Id;

    });


console.log(records);


var filteredList = records.filter(function(record) {

    

    return record.Status == “Started”;

    

});


console.log(filteredList);

Hey Elissa, if you want to filter the rows, you’ll need to return the row, not the row Id, from your $.map() call: 

    var records = skuid.$.map(argumentsm0].list.getSelectedItems(),function(item){ 
        return item.row;
    });


Also, as a shortcut, you can combine the map and filter calls: 


var startedCases =&nbsp;skuid.$.map(argumentss0].list.getSelectedItems(),function(item){&nbsp;<br>&nbsp; &nbsp;return item.row;<br>}).filter(function(row) {<br>&nbsp; &nbsp;return row.Status === "Started";<br>});