function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BA_AdminBA_Admin 

Help in Visualforce Dashbboard Component

Hi All,

      According to the code below,  i can display the open cases in dashboard belonging only to Babara Levy, but i need the cases to be displayed according to the user when he/she logs into sfdc, for example if i login then i should see my cases in dashboard, and if other users logs into sfdc then they should be able to see their own cases in dashboard, can anyone plz help me with what are the changes to be done in class,iam need to sfdc.

 

VF PAGE:

 

<apex:page controller="retrieveCase" tabStyle="Case">
<apex:pageBlock>
{!contactName}'s Cases
<apex:pageBlockTable value="{!cases}" var="c">

<apex:column value="{!c.status}"/>
<apex:column value="{!c.subject}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

CLASS:

 

public class retrieveCase {
public String getContactName() {
return 'Babara Levy';
}
public List<Case> getCases() {
return [SELECT status, subject FROM Case
WHERE Contact.name = 'Babara Levy' AND status != 'Closed' limit 5];
}
}

 

 

Thx in Advance!

Best Answer chosen by Admin (Salesforce Developers) 
sravusravu

Make the following changes to your apex class:

 

public class retrieveCase {
public String uname{get;set;}
public String getContactName() {
uname=UserInfo.getName(); // will get the current user name
return uname;

}
public List<Case> getCases() {
return [SELECT status, subject FROM Case
WHERE Contact.name = :uname AND status != 'Closed' limit 5];
}
}

 

Hope this helps you....

Please let me know if you face any difficulty.

All Answers

sravusravu

Make the following changes to your apex class:

 

public class retrieveCase {
public String uname{get;set;}
public String getContactName() {
uname=UserInfo.getName(); // will get the current user name
return uname;

}
public List<Case> getCases() {
return [SELECT status, subject FROM Case
WHERE Contact.name = :uname AND status != 'Closed' limit 5];
}
}

 

Hope this helps you....

Please let me know if you face any difficulty.

This was selected as the best answer
BA_AdminBA_Admin

Hey thank you so much for your the code, i really appreciate and it worked for me

sravusravu

Accept it as a solution if this resolved your issue.

Thanks