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) 
super developersuper developer

You need change here

 

return [SELECT status, subject FROM Case
WHERE Contact.name = 'Babara Levy' AND status != 'Closed' and ownerid=:userinfo.getUserId()];

 

Try this..