function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gary Payne 9Gary Payne 9 

Need help with an Apex Controller Class

We have an Apex Class Controller that needs to be altered to prevent Cases with a Type field value of "Project" from being included in the view.  Following is our Apex Class code:
public with sharing class ANICasesListViewController
{
    public String all_cases_list_view {get;set;}
    public String customer_service_list_view {get;set;}
    public String technical_support_list_view {get;set;}
    private Static String ALL_CASES = 'All Cases';
    private Static String CustomerService_CASES = 'Customer Service';
    private Static String TechnicalSupport_CASES = 'Technical Support';
     
   public ANICasesListViewController(ApexPages.StandardSetController controller) {
           String case_query = 'SELECT Id FROM Case LIMIT 1';
           all_cases_list_view = getListView( case_query , ALL_CASES );
           customer_service_list_view = getListView( case_query , CustomerService_CASES );
           technical_support_list_view = getListView( case_query ,TechnicalSupport_CASES );        
    }
    public static String getListView( String casequery, String listviewname )
    {
        String listviewid = null;

       ApexPages.StandardSetController ssc =  new ApexPages.StandardSetController(Database.getQueryLocator(casequery));

        List<SelectOption> listViewsAll = ssc.getListViewOptions();

        for (SelectOption so : listViewsAll)
        {
            if (so.getValue() == listviewname )
            {
                listviewid = so.getValue();
                break;
            }
        }
        if( listviewid != null )
        {
            // for some reason, won't work with 18 digit ID
            listviewid = listviewid.substring(0,15);
        }

        return listviewid;       
    }

}

Where in this code can the Type field value of "Project" be eliminated from the view and what would the code be?  Any help is greatly appreciated.
Best Answer chosen by Gary Payne 9
Jayamaruthyraman JaganathJayamaruthyraman Jaganath
I guess you would modify your SELECT statement (case_query ) to the following:

'SELECT Id FROM Case Where Type != 'Project' LIMIT 1';

All Answers

Jayamaruthyraman JaganathJayamaruthyraman Jaganath
I guess you would modify your SELECT statement (case_query ) to the following:

'SELECT Id FROM Case Where Type != 'Project' LIMIT 1';
This was selected as the best answer
Gary Payne 9Gary Payne 9
Thanks for the quick reply Jayamaruthyraman, I had to add the regular quotes around the value “Project”. It is working. Regards, Gary Payne Salesforce Administrator ABILITY® One Metro Center
4010 Boy Scout Blvd. Suite 900
Tampa, FL 33607 P 813.580.5603 | C 714.474.5915 abilitynetwork.com
Jayamaruthyraman JaganathJayamaruthyraman Jaganath
Can you please mark it as resolved and like my response please?