You need to sign in to do that
Don't have an account?
Nitin Sharma
I want to create a vf page for displaying account in two section One for Active account and another for Inactive account. depend on search string.
I created vf page and controller but while I am searching, getting an error
''line 1:56 no viable alternative at character '"'
Error is in expression '{!search}' in component <apex:commandButton> in page testactiveacc: Class.activeAccount.search: line 18, column 1
"
Vf page
Controller class
''line 1:56 no viable alternative at character '"'
Error is in expression '{!search}' in component <apex:commandButton> in page testactiveacc: Class.activeAccount.search: line 18, column 1
"
Vf page
<apex:page standardController="Account" extensions="activeAccount" tabStyle="Account"> <apex:form > <apex:sectionHeader title="User Global Search" subtitle="Result"/> <apex:pageBlock > <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > <label>Quick Search</label> <apex:outputPanel > <apex:inputText value="{!searchstring}" label="Input"/> <apex:commandButton value="Search records" action="{!search}" reRender="pgId1,pgId2" status="ajaxId"/> <apex:actionStatus startText="Searching..." id="ajaxId"></apex:actionStatus> </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Search Active Result" id="pgId1"> <apex:pageblockTable value="{!acc}" var="a"> <apex:column headerValue="Name" > <apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink> </apex:column> <apex:column headerValue="Active" > <apex:outputlink >{!a.Active__c}</apex:outputlink> </apex:column> <apex:column value="{!a.id}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Search Inactive Result" id="pgId2"> <apex:pageblockTable value="{!acc1}" var="a"> <apex:column headerValue="Name" > <apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink> </apex:column> <apex:column headerValue="Active" > <apex:outputlink >{!a.Active__c}</apex:outputlink> </apex:column> <apex:column value="{!a.id}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Controller class
public with sharing class activeAccount { public list <Account> acc {get;set;} public list <Account> acc1 {get;set;} public string searchstring {get;set;} public string value1 {get;set;} public activeAccount (ApexPages.StandardController controller) { } public void search(){ if(searchstring != null && searchstring != '' ){ string searchquery='select Name, id,Active__c from Account where Active__c ="Yes" AND Name like \'%'+searchstring+'%\' Limit 10'; string searchquery1='select Name, id,Active__c from Account where Active__c ="No" AND Name like \'%'+searchstring+'%\' Limit 10'; acc = Database.query(searchquery); acc1 = Database.query(searchquery1); } } }Code not working. Can any one help.
All Answers
But I am not able to override account tab with this VF page.
Can you help
1) Setup -> Accounts -> Button Links and Actions -> Select the button you want to override (View)-> Select Visualforce Page -> Select your page.
As I have trige in my org and it's working.
1) Setup -> Accounts -> Button Links and Actions -> Account Tab->Edit-> Select Visualforce Page ->
VF page not available in list...
Also you need to create a new Constructor like below