I am trying to use the apex metadata api I found here: https://github.com/financialforcedev/apex-mdapi
I want to get all of the filters and other properties of Lead Views. I looked at the example code for readListView()
I ran the following code on my org:
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.ListView leadView = (MetadataService.ListView) service.readMetadata('ListView', new String[] { 'Lead.Test_Lead_View' }).getRecords()[0];
and when I ran it all the Lead Views I looked at had null filters, as well as basically all of the fields listed here https://www.salesforce.com/us/developer/docs/api_meta/Content/meta_listview.htm. It even had a null fullName this should definitely not be the case as these lead views definitely have filters set on them and I searched for them by fullName.
Once this had failed I tried to use the Metadata Retrieve Demo provided by that library to see if I had just failed to use the API properly. When I selected the ListView Metadata Type it successfully listed all of my List Views and I selected the one I wanted to retrieve, but there was also a "Metadata Folder" field and I have no idea what to set that field to, and without it set I get the following error: "null: Need to specify full name, Name:, Delimiter:."
Am I doing something wrong with either of these methods of getting Lead View metadata? Is there a better way I could get this information via Apex? My end goal is to be able to recreate a Lead View as an SOQL query.