I followed instructions given in https://github.com/financialforcedev/apex-mdapi to create list views in my dev org. I am trying to create List View for Accounts.
I am able to create simple list without any issues. But I when I tried to add a filter and list of columns, I am getting FIELD_INTEGRITY_EXCEPTION error
I appreciate if any one can help narrow down the issue
Here is the code I am using
MetadataService.MetadataPort service = MetadataService.createService();
MetadataService.ListView listView = new MetadataService.ListView();
MetadataService.ListViewFilter filter = new MetadataService.ListViewFilter();
List<MetadataService.ListViewFilter> filterListToAdd = new List<MetadataService.ListViewFilter>();
listView.fullName = 'Account.' + newlistview;
listView.label = newlistview;
filter.field = 'Account.ACCOUNT NAME';
filter.operation = 'equals';
filter.value = 'Acme';
filterListToAdd.add(filter);
System.debug('ListViewController::createnew creating ' + listView.fullName);
listView.filters = filterListToAdd;
listView.filterScope = 'Everything';
listView.columns = new List<String> { 'Account.Account Name','Account.OwnerId','Account.Type'};
listView.columns = new List<String> { 'Account.Name'};
List<MetadataService.SaveResult> results = service.createMetadata(new MetadataService.Metadata[] { listView });
MetadataService.handleSaveResults(results[0]);