public without sharing class searchAimsAccount { public String SearchName {get;set;} private String accountid = null; private String accName = null; private String protype = null; public List at {get;set;} public searchAimsAccount() { accountId = ApexPages.currentPage().getParameters().get('accId'); accName = ApexPages.currentPage().getParameters().get('accName'); // DB202309406949 gzw start protype = ApexPages.currentPage().getParameters().get('protype'); } public void init(){ String soql = makeSoql('',accountId); at = Database.query(soql); } public PageReference serContact(){ at = Database.query(this.makeSoql(SearchName,accountid)); return null; } private String makeSoql(String searchName,String accountid){ String soql = 'SELECT id,Name,State_Master__c,State_Master__r.Name,Address__c FROM Account'; if (accountId != null && accountId != '') { soql += ' where id in (SELECT Hospital__c FROM Agency_Hospital_Link__c WHERE Agency__c = :accountid ' ; }else{ soql += ' where id in (SELECT Hospital__c FROM Agency_Hospital_Link__c WHERE Agency__r.Name = :accName ' ; } if (protype == 'ENG' ) { soql += 'and AgencyHos_ENG__c = true ) '; }else{ soql += 'and AgencyHos_ET__c = true ) '; } if(String.isNotBlank(searchName)){ soql += ' AND Name like \'%' + SearchName+ '%\''; } soql += ' order by Name desc limit 200 '; return soql; } /*public List ahlList; public List AgencyHospitalLinkList { get; set; } public List AccountList {get;set;} public String accountId{get;set;} public searchAimsAccount() { accountId = ApexPages.currentPage().getParameters().get('accId'); AgencyHospitalLinkList = new List(); system.debug('accountId' + accountId); } public void init(){ system.debug(accountId + 'accountId'); ahlList = [select Hospital__c, Hospital__r.name,Agency__c from Agency_Hospital_Link__c where Agency__c = :accountId and AgencyHos_ENG__c = true limit 200 ]; for(Agency_Hospital_Link__c ahl_c : ahlList){ searchAgencyHospitalLink ahl = new searchAgencyHospitalLink(ahl_c); AgencyHospitalLinkList.add(ahl); } } class searchAgencyHospitalLink{ public Agency_Hospital_Link__c ahlc { get; set;} public searchAgencyHospitalLink(Agency_Hospital_Link__c ahl_c){ ahlc = ahl_c; } }*/ }