+ Start a Discussion

Getting information on cases associated with a user and displaying an on-screen prompt

I have a visualforce page that shows a variety of information.  I want the page to be able to get the userID, then go to the cases object and check for cases where that user is the main contact and where the case is a specific status.  


If the status is "More information needed" or "Solution sent" I want to display some text on the page to say 1 or more case needs attention.  If no cases are on those statuses I want to display there are no cases that need attention.


Can anyone advise me how I would get started with this?


Hi Alanistic,

Do you have a custom controller for your page?


If not, you will need to start by creating one, I assume you are using the standard controller, in which case you will need to add your custom controller as an extention.


In your custom controller you can query for cases where the main contact is equal to UserInfo.getUserId() which is the current logged in users id. And where the status is "more information needed" or "solution sent".


Then in your page you can check the number of returned results, if size == 0  set the outputText of "There are no cases that need attention" to renderd = true, and then the opposite for the other message.


I hope this helps!