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

Displaying Users along with related accounts and contacts
Hi All
How to display users, under perticular user I want to display related accounts & contacts (without commandlinks)
Example:
UserName:YYYYYYYY
Accountname accountnumber phone etc(i.e account details)
Contact: xxxxxxxx
Thanks &Regards
Anitha
By related Accounts, do you mean Owned by User ?
Hi
yes Related accounts means, which user created records
UserId uId = UserInfo.getUserId();
for (Account acc : [Select Id, Name, (Select Id, Name from Contacts) where CreatedById = :uId)
{
System.debut('Account' + acc.Name);
for (Contact con : acc.Contacts)
System.debug (con.Name);
}
You need to query all the fields whcih ever you need,
Eg
list<Account> acc = [SELECT Name, ( SELECT LastName FROM Contacts WHERE CreatedBy.Alias = 'x') FROM Account WHERE CreatedBy.Alias = 'x'];
then put this in pageblock table and display it in a page.
Mark this as best answer if its helps.
Thanks.
Praveen Murugesan