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 

Help with apex code to filter Account records for a Status of "Active"

We have a VF page in a community to display Accounts when the user clicks the My Customers tab.  What would be the apex code I need to add to the following controller apex code to filter for Account_Status__c = 'Active'?

public without sharing class ANIMyAccountsController {

    public ANIMyAccountsController(ApexPages.StandardController controller) {
    }

    public List<Account> getAccountsList()
    {
       return [Select id,name,vendor__C,Phone,Type,Ownerid,BillingState,BillingStreet,BillingCity,BillingPostalCode,Primary_Line_of_Business__c,Tax_ID__c, Tax_Status__c, NPI_Org__c, Medicare_Provider_ID__c from Account where vendor__C = :userinfo().accountid];
    }

     private user userinfo(){
        return [Select id,name,profile.name,accountid from User where id=:UserInfo.getUserId()];
    }

}  
 
sailee handesailee hande
Hi Gary,

Just put Account_Status__c = 'Active' in soql as :

Select Account_Status__c,id,name,vendor__C,Phone,Type,Ownerid,BillingState,BillingStreet,BillingCity,BillingPostalCode,Primary_Line_of_Business__c,Tax_ID__c, Tax_Status__c, NPI_Org__c, Medicare_Provider_ID__c from Account where vendor__C = :userinfo().accountid AND Account_Status__c = 'Active'

let me know if this works for you.

Regards,
Sailee