I need to get records based on recordtypeid and listviewid but it is returning all records. I don't know where I'm doing it wrong.(it will return records based on listview but recordtypeid condition is not applying).

String strquery = 'SELECT Id, Type,Status,Contact.Name,Origin FROM Case WHERE recordtypeID =: rtId LIMIT 500';
List<SObject> record  = queryRecords(Database.getQueryLocator(queryString), listViewID);

private static List<SObject> queryRecords(Database.QueryLocator sobjRecords, String ListId){
    ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(sobjRecords);
    return ssc.getRecords();
    }catch(Exception e){
        throw new AuraHandledException( e.getMessage() );


Your Answer

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

Browse other questions tagged or ask your own question.