Visualforce page to display Account Information based on User input.
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 !
cheers
ReplyDeleteHi There,
ReplyDeleteThis is indeed great! But I think perhaps you are generally referring Visualforce page to display Account Information based on User input. which is getting unsustainable.
I have an apex datatable returning some User fields from a list in my apex class. I would like to include a column "This Month's Sales" which would return the total $ of opps closed won this month. I can run the SOQL in my class but I'm not sure how to get the correct result per user into the table, i.e. how to put it into the correct row and column in my table. Can I attach this $amount to each user without creating a custom field?
I am so grateful for your blog. Really looking forward to read more.
Kind Regards,
Preethi.