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

Different visualforce page view based on User logged in.
Hi good people,
I have a visualforce page that displays a list of unresolved emails record.However,i would like each user to be able to view only his records i.e owner.name == user.name.Thus only view records that he/she owns.
Below is my visualforce page.
<apex:page controller="UnresolvedEmailsController" > <apex:form > <apex:pageBlock title="Unresolved Emails" mode="edit"> <apex:pageBlockTable value="{!unresolvedEmails}" var="Emails" > <apex:column > <apex:facet name="header">Subject</apex:facet> <apex:outputlink value="/{!Emails.id}"> <apex:outputField value="{!Emails.Name}"/> </apex:outputlink> </apex:column> <apex:column > <apex:facet name="header">From</apex:facet> <apex:outputField value="{!Emails.From__c}"/> </apex:column> <apex:column > <apex:facet name="header">Assigned To</apex:facet> <apex:outputField value="{!Emails.Assigned_To__c}"/> </apex:column> <apex:column > <apex:facet name="header">Owner</apex:facet> <apex:outputField value="{!Emails.owner.name}"/> </apex:column> <apex:column > <apex:commandButton value="New Contact" action="{!newContact}" reRender="hiddenBlock"> <apex:param name="unresolvedEmailId" value="{!Emails.id}" assignTo="{!unresolvedEmailId}"/> </apex:commandButton> <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock> </apex:column> </apex:pageBlockTable> <apex:panelGrid columns="4" style="text-align: center; vertical-align: middle;"> <apex:commandLink action="{!first}">First</apex:commandlink> <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink> <apex:commandLink action="{!last}">Last</apex:commandlink> </apex:panelGrid> </apex:pageBlock> </apex:form> </apex:page>
Hi Sayasoni,
Try adding the condition owner.name==user.name to your soql query.
In your case, if the user does not have "view all" permission for whatever object you are querying , he won't be able to see others emails.
1)the organization wide setting for your object should be "private"
2)remove "view all" profile on the profile for that object
in this case it will query only the ones the person owns.
Hope this helps,
Sid
All Answers
Hi Sayasoni,
Try adding the condition owner.name==user.name to your soql query.
In your case, if the user does not have "view all" permission for whatever object you are querying , he won't be able to see others emails.
1)the organization wide setting for your object should be "private"
2)remove "view all" profile on the profile for that object
in this case it will query only the ones the person owns.
Hope this helps,
Sid
Thanks alot Sid, that was so straight forward.I still can't believe i didn't see that one.