You need to sign in to do that
Don't have an account?
SalesforceLearner
How to display Accounts & its related opportunities of a login User in Vf page
I am able to display All accounts with opportunities but I want to display it based on the login User.
Does anyone know how to display currently login user Accounts & its opportunities?
Does anyone know how to display currently login user Accounts & its opportunities?
--
Thanks,
Swayam
@salesforceguy
All Answers
ID contactId = [Select contactid from User where id =: Userinfo.getUserid()].contactId;
ID AccID = [Select AccountID from Contact where id =: contactid].AccountId;
then with this account id you can proceed, Let me know if you have any doubts
--
Thanks
Swayam
@salesforceguy
Here is my controller :
public void getData(){
userid = Userinfo.getUserId();
List<Opportunity> Opps = [Select name,Id,AccountId,Amount from Opportunity];
Set<id> parentIdSet = new Set<id>();
for(Opportunity OppertunityRec :allOpps){
parentIdSet.add(OppertunityRec.AccountId);
}
//get all associated parents
List<Account> allAccounts = [Select name,id,AnnualRevenue,Industry from Account where Id IN : parentIdSet];
wrapperList = new list<myWrapperClass>();
//For loop to set data
for(Opportunity childRec : allOpps){
//myWrapperClass wrapRec;
for(Account parentRec :allAssocaiatedAccounts){
if(parentRec.Id == childRec.AccountId){
myWrapperClass wrapRec = new myWrapperClass();
wrapRec.acc = parentRec;
wrapRec.opp = childRec;
wrapperList.add(wrapRec);
}
}
}
--
Thanks,
Swayam
@salesforceguy
Hope This Help
--
Thanks,
Swayam
@salesforceguy