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
Sky1990Sky1990 

Columns & Data Not Visible on VF Page - Case Milestone

Hi ,  I am not able to display some fields on VF Page when using Apex Controller.

I have 2 object
1. Case
2. Case Dummy

I store Case Id in my Case dummy to be able to relate between them.

Below is my Code:
 VF Page:
<apex:page standardController="Case_Proxy__c" extensions="CaseMilestoneUtils">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="1" >
                <apex:pageblockTable value="{!CaseMilestones}" var="milestone">
                    <apex:column headerValue="Milestone Id" value="{!milestone.Id}"/>
                    <apex:column headerValue="Completion Date" value="{!milestone.CompletionDate}"/>
                    <apex:column headerValue="Completed" value="{!milestone.IsCompleted}"/>
                    <apex:column headervalue="Action" >                    
                            <apex:commandButton value="Mark As Complete" rendered="{!IF(milestone.IsCompleted == true,false,true)}" action="{!markMilestoneComplete}" reRender="hiddenBlock" >
                                <apex:param name="milestoneID" value="{!milestone.Id}" assignTo="{!milestoneID}" />
                            </apex:commandButton> 
                    </apex:column>                    
                </apex:pageblockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
    </apex:form>
</apex:page>

Apex Code:
public without sharing class CaseMilestoneUtils{

    public CaseMilestoneUtils(ApexPages.StandardController controller) {
        stdCtrl=controller;
        refreshPage=false;
    }

    public List<CaseMilestone> milestones = null;
    public string Case_Id = null;
    public string milestoneID {get; set{milestoneID = value;}}
    public ApexPages.StandardController stdCtrl {get; set;}
    public Boolean refreshPage {get; set;}
         
    // Fetch the Id for the case Lite Records opened
    public string Case_Lite_Id = ApexPages.CurrentPage().getparameters().get('id');

    // Fetch the Case Id from the case_Proxy object based on the Case Lite Id
    public List<Case_Proxy__c> CaseProxy = [SELECT Case__c FROM Case_Proxy__c WHERE Id =: Case_Lite_Id LIMIT 1];

    // Displays all Milestones related to a Case 
    public List<CaseMilestone> getCaseMilestones(){
        if(CaseProxy.size() != 0){
            for(Case_Proxy__c Proxy : CaseProxy){
                Case_Id = Proxy.Case__c;
            }
            if(milestones == null) milestones = [SELECT Id, CompletionDate, IsCompleted FROM CaseMilestone WHERE CaseId =: Case_Id];
            return milestones;
        }
        return null;
    }
    
    // Method to Update the Case Milestone as Completed
    // It sets a particuler milestone to completed which is selected to be set to IsComplete
    public PageReference markMilestoneComplete(){
    
        if(milestoneID != null){
            CaseMilestone milestone = [SELECT Id,CompletionDate,IsCompleted FROM CaseMilestone WHERE Id  =: milestoneID LIMIT 1];
                        
            if(milestone.IsCompleted != true){
                milestone.CompletionDate = DateTime.now();        
                update milestone;
            }   
            refreshPage=true;
            stdCtrl.save();     
        }
        
        PageReference pageRef = new PageReference('/apex/ViewPageMilestones');
        pageRef.setRedirect(true);
        return pageRef;
    }
}

When I run the above code as an Admin Profile i am able to see the Columns and Data on VF page. But when i view it as a specific User with different profile i can't see the colums and data, i only see the "mark as complete " button column with a button for each record,not the rest of the columns.

Please suggest what might be going wrong. 
surasura
make sure the relevant user's profile has at least read permission on the CaseMilestone object , also check the field level accesss on the same object for the above users profile
Sky1990Sky1990
Hi, CaseMilestone is an object which is created when we enable entitlements in salesforce. It is a standard object. I could not find it's object level or Field Level Permissions. Can you let me know where i can make the required settings. Thanks Sent from my Sony Xperia™ smartphone ---- Salesforce Developer Community wrote ----
surasura
according to documention user need To view case milestones: “Read” on cases
                                                      To edit case milestones: “Edit” on cases


for more info refer https://help.salesforce.com/HTViewHelpDoc?id=cases_milestones.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=cases_milestones.htm&language=en_US)
Sky1990Sky1990
Do these access rules apply even if my code is running in Without Sharing mode. Thanks, Sent from my Sony Xperia™ smartphone ---- Salesforce Developer Community wrote ----
Sky1990Sky1990
So, of i just give read permission on case object to my users then my complete code should work fine??? Thanks ---- Salesforce Developer Community wrote ----
Sky1990Sky1990
So, of i just give read permission on case object to my users then my complete code should work fine??? Thanks ---- Salesforce Developer Community wrote ----
surasura
in your case when using standard controllers objected level secruity get applied irrespictive of  without sharing keyword (you query returns the records but they are hidden from the view)
Sky1990Sky1990
Any other way to solve this issue.