You need to sign in to do that
Don't have an account?

Show accounts of selected user
Hi,
I want to code a visual force which shows me the accounts of the selected user.
I have the code below, but I don't know how can I create a list of account of the selected user.
I read something about the actionsuppert onchange, but I'm not sure how it works.
Thanks,
Sascha
I want to code a visual force which shows me the accounts of the selected user.
I have the code below, but I don't know how can I create a list of account of the selected user.
I read something about the actionsuppert onchange, but I'm not sure how it works.
<apex:page controller="VTP3_class"> <apex:form > <apex:pageBlock > <apex:pageBlockSection > <apex:OutputPanel > <apex:selectList value="{!SelectedUserId}" size="1" multiselect="false" > <apex:selectOptions value="{!ListOfUser}" /> </apex:selectList> </apex:OutputPanel> </apex:pageBlockSection> </apex:pageBlock> <apex:pageblock > <apex:pageblocktable value="{!AccList}" var="Acc"> <apex:column headervalue="Unternehmen"> <apex:outputfield value="{!Acc.Name}" /> </apex:column> <apex:column headervalue="Straße"> <apex:inputfield value="{!Acc.BillingStreet}" /> </apex:column> <apex:column headervalue="Stadt"> <apex:inputfield value="{!Acc.BillingCity}" /> </apex:column> </apex:pageblocktable> </apex:pageblock> </apex:form> </apex:page>
public class VTP3_class { Public String selecteduserId {set;get;} Public List<Account> AccList {get;set;} Public VTP3_class() { AccList = [SELECT Name, BillingStreet, BillingPostalCode, BillingCity FROM Account WHERE OwnerId = :SelectedUserId]; } Public List<SelectOption> getListOfUser() { List<User> Users = [SELECT Id, Username, Name FROM User] ; List<SelectOption> UserOptionList = new List<SelectOption>(); UserOptionList .add(new SelectOption( ' ' ,'---Select---')); for(User u : Users ) { UserOptionList .add(new SelectOption(u.Id , u.Name)); } return UserOptionList ; } }
Thanks,
Sascha
You can create a method and then onchange of user from user list you can call that method ...
Something like, you need to additionally add these..
onchange of user you will call this method and rerender the block ..
<apex:actionfunction name="fetchAll" action="{!fetchAllAccounts}" rerender = "pageblockid"/>
<apex:selectList value="{!SelectedUserId}" size="1" multiselect="false" onchange="fetchAll();" >
<apex:selectOptions value="{!ListOfUser}" />
</apex:selectList>
Please implement above and let me kbow if it solves your need..
Thanks
All Answers
You can create a method and then onchange of user from user list you can call that method ...
Something like, you need to additionally add these..
onchange of user you will call this method and rerender the block ..
<apex:actionfunction name="fetchAll" action="{!fetchAllAccounts}" rerender = "pageblockid"/>
<apex:selectList value="{!SelectedUserId}" size="1" multiselect="false" onchange="fetchAll();" >
<apex:selectOptions value="{!ListOfUser}" />
</apex:selectList>
Please implement above and let me kbow if it solves your need..
Thanks
Thanks for your response, it is working but I have a new question.
If I click a accountname the page should show me a list of opportunities of this account.
I code someting (see below), but it doesn't work.
Thanks,
Sascha
try with this.