1

I want to get List View Columns using Metadata available for ListViews. I have the Id and FullName of List Views but I want to get Column and Filter values using Id or Fullname. I am currently using SOAP Api but as it is not supported in lightning(Error 401), I want to use List View Id or FullName to get List View Columns and Filter criteria.. Thanks In advance!

0

you can access Listview Columns,Filter Filte scope by Using MetatadataAPI check out here for how to use MetatadataAPI via Apex.

public class SFMetadataAPIService {
public static void readListViewMD() {
    MetadataService.MetadataPort service = buildMDAPIService();
    MetadataService.ListView listView= (MetadataService.ListView) service.readMetadata(
        'ListView', new String[] { 'Account.businessAccounts' }
    ).getRecords()[0];

    if(listView.columns!=null)
        for(String column : listView.columns)
            System.Debug('Column ' + column)
    ;
    if(listView.filters!=null)
        for(MetadataService.ListViewFilter filter : listView.filters)
            System.Debug('Filter ' + filter.field + ' ' + filter.operation + ' ' + filter.value)
    ;
}
public static MetadataService.MetadataPort buildMDAPIService() {
    MetadataService.MetadataPort service= new MetadataService.MetadataPort();
        service.SessionHeader  = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId     = UserInfo.getSessionId();
      return service;
   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.