Requirement: User enters Account Name and clicks command button to get Account details.
Solution: This can be achieved by writing Visualforce page.
Visualforce page:
Entering the Account name : Blackbeards Grog Emporium
Visualforce page:
<apex:page controller="DisplayAccountDtlController" >
<apex:form >
<apex:pageBlock title="Accounts">
<apex:pageBlockButtons >
<apex:commandButton value="Display Data" action="{!getdata}" />
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:outputLabel value="Enter Account Name" />
<apex:inputText value="{!accname}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.industry}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class DisplayAccountDtlController {
public list<account> acc {set;get;}
public string accname {set;get;}
public void getdata(){
acc = [select name, industry from account where name = :accname];
}
}
Cheers !
Solution: This can be achieved by writing Visualforce page.
Visualforce page:
Entering the Account name : Blackbeards Grog Emporium <apex:page controller="DisplayAccountDtlController" >
<apex:form >
<apex:pageBlock title="Accounts">
<apex:pageBlockButtons >
<apex:commandButton value="Display Data" action="{!getdata}" />
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:outputLabel value="Enter Account Name" />
<apex:inputText value="{!accname}"/>
</apex:pageBlockSection>
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.industry}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class DisplayAccountDtlController {
public list<account> acc {set;get;}
public string accname {set;get;}
public void getdata(){
acc = [select name, industry from account where name = :accname];
}
}
Cheers !


0 Comments