I've an requirement where I'm adding a new filter for the list views through apex code since we have 1000+ list views in prod. Below I've added a new filter where lead status not equal to closed and it worked

MetadataService.ListView listView = new MetadataService.ListView();
           MetadataService.ListViewFilter filter = new MetadataService.ListViewFilter();
           List<MetadataService.ListViewFilter> newFilterList = new List<MetadataService.ListViewFilter>();
           MetadataService.SharedTo share = new MetadataService.SharedTo();
           listView.columns = listColumns;
           listView.fullName = listType + '.' + g.DeveloperName;
           listView.label = g.Name;
           filter.field = 'LEAD.STATUS';
           filter.operation = 'notEqual';
           filter.value = closed;

           listview.filters = newFilterList;
           listView.filterScope = 'Queue';

Now I want to add a new filter where lead status is equal to 'new', 'unactioned' etc. How can I assign multiple values to the filter.value in the code. Please help

  • I believe it's as simple as having the value be a comma-separated list as a string, just as it would be in the UI. Give it a try. filter.value = 'New,Unactioned'
    – sfdcfox
    Oct 26, 2022 at 15:50
  • Thank you. It's working now
    – Viswanath
    Oct 26, 2022 at 19:25


You must log in to answer this question.

Browse other questions tagged .