+ Start a Discussion
prady-cmprady-cm 

Record visible in one VF page but not visible on another VF page

I have 2 VF pages which are similar and the controllers are similar too.

The only difference is that the first VF page accepts user to fill in the dates and queries the records within that date range.

 

The second VF is uses the dates from query string.

 

I get the same records in both the pages except that there is one field which comes as null for some records only.

I cant see what could cause this. Cant be a security issue as the same values are visible in one Vf page.

 

Here is the code for both pages

 

VFpage which is causing the Event__r.name not to display for some records only

 

 <apex:datatable value="{!LstOutgoingShipments}" columns="14"  var="inShip"  width="100%" cellpadding="2" cellspacing="2" columnsWidth="30px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px" rules="all" id="dtshiprec">
 
 <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Departed</apex:facet>
 <apex:outputField value="{!inShip.Shipment_Departed__c}"/>
 </apex:column>
 
  <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Equipment</apex:facet>
 <apex:outputText value="{!inShip.Equipment__r.name}"/>
 </apex:column>
 
 <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Event</apex:facet>
  <apex:outputText value="{!inShip.Event__r.name}"/>
 </apex:column>
 
  <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship from <br/>Location</apex:facet>
  <apex:outputText value="{!inShip.Ship_From_Location__r.name}"/>
 </apex:column>
   <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Estimated<br/> Dep Time</apex:facet>
  <apex:outputField value="{!inShip.Est_Departure_Time__c}"/>
 </apex:column>
 
     <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship To<br/> Location</apex:facet>
  <apex:outputText value="{!inShip.Ship_To_Location__r.name}"/>
 </apex:column>

       <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Estimated <br/>Arrival Time</apex:facet>
  <apex:outputfield value="{!inShip.Estimated_Arrival_Time__c}"/>
 </apex:column>
        <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship To <br/>Instructions</apex:facet>
  <apex:outputText value="{!inShip.Ship_To_Instructions__c}"/>
 </apex:column>
 
         <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Carrier</apex:facet>
  <apex:outputText value="{!inShip.Shipping_Carrier__c}"/>
 </apex:column>
 
          <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Driver</apex:facet>
  <apex:outputText value="{!inShip.Shipping_Driver__c}"/>
 </apex:column>
 
           <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Driver Phone</apex:facet>
  <apex:outputText value="{!inShip.Shipping_Driver_Phone__c}"/>
 </apex:column>
 
            <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Post Event Instructions</apex:facet>
  <apex:outputText value="{!inShip.Post_Event_Instructions__c}"/>
 </apex:column>
 
            <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">No Of <br/>Rolling Cases</apex:facet>
  <apex:outputText value="{!inShip.No_of_Rolling_Case__c}"/>
 </apex:column>
 
            <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">No Of <br/>HD Cases</apex:facet>
  <apex:outputText value="{!inShip.No_of_HD_Case__c}"/>
 </apex:column>
 
 </apex:datatable>

</apex:page>

 Controller for the page which is not displaying one field for some records

 

public with sharing class PrintShipDepartedController {
    public List<Event_Equipment__c> LstOutgoingShipments= new List<Event_Equipment__c>();
    public List<Event_Equipment__c> LstIncomingShipments=new List<Event_Equipment__c>();
    
    public List<user> LstCurrentUserAccount= new List<user>();
    Id userid;
    public date startdate1 {get; set;}
    public date enddate1 {get; set;}     
    
     public List <Event_Equipment__c> getLstOutgoingShipments() {
        return LstOutgoingShipments;
    }
    public List <Event_Equipment__c> getLstIncomingShipments() {
        return LstIncomingShipments;
    }
    string CurrentUserAccount='';
    public PrintShipDepartedController()
    {
        startdate1=date.valueof(ApexPages.currentPage().getParameters().get('Pstartdate'));
        enddate1=date.valueof(ApexPages.currentPage().getParameters().get('Penddate'));
       Loaddata();
       
    }
    
    public void LoadData()
    {
        userid = UserInfo.getUserId();
        LstCurrentUserAccount=[select id,Related_Account__c from user where id=:userid];
        If (LstCurrentUserAccount.size()>0)
         CurrentUserAccount=LstCurrentUserAccount[0].Related_Account__c;
        LstOutgoingShipments=[select id,
                            Equipment__r.name,  // this field is one which is not displaying  for some records
                            Event__r.name,
                            Event_Date__c,
                            Ship_From_Location__r.name,
                            Ship_From_Vendor__r.name,
                            Est_Departure_Time__c,
                            Ship_To_Location__r.name,
                            Ship_To_Vendor__r.name,
                            No_of_Rolling_Case__c,
                            No_of_HD_Case__c,                           
                            Estimated_Arrival_Time__c,
                            Ship_To_Instructions__c,
                            Shipping_Carrier__c,
                            Shipping_Driver__c,
                            Shipping_Driver_Phone__c,
                            Post_Event_Instructions__c, 
                            Shipment_Departed__c,
                            Shipment_Received__c from Event_Equipment__c 
                            where Ship_From_Vendor__c=:CurrentUserAccount and DAY_ONLY(Est_Departure_Time__c)>=:startdate1 and DAY_ONLY(Est_Departure_Time__c)<=:enddate1 ];

         LstIncomingShipments=[select id,
                            Equipment__r.name,
                            Event__r.name,
                            Event_Date__c,
                            Ship_From_Location__r.name,
                            Ship_From_Vendor__r.name,
                            Est_Departure_Time__c,
                            Ship_To_Location__r.name,
                            Ship_To_Vendor__r.name,
                            No_of_Rolling_Case__c,
                            No_of_HD_Case__c,                           
                            Estimated_Arrival_Time__c,
                            Ship_To_Instructions__c,
                            Shipping_Carrier__c,
                            Shipping_Driver__c,
                            Shipping_Driver_Phone__c,
                            Post_Event_Instructions__c, 
                            Shipment_Departed__c,
                            Shipment_Received__c from Event_Equipment__c 
                            where Ship_To_Vendor__c=:CurrentUserAccount and DAY_ONLY(Estimated_Arrival_Time__c)>=:startdate1 and DAY_ONLY(Estimated_Arrival_Time__c)<=:enddate1 ];

    }

}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Niket SFNiket SF

According to me it's should not happen there must be any sharing rules which are giving access to some record. Please check with that without sharing and with sharing Keyword in your class.

 

Thanks

Nik's

Skype name : Niket Chandane

 

All Answers

prady-cmprady-cm

Continued from above post.

 

This VF page displays values correctly

 

<apex:page controller="ctrl_shipments"  sidebar="false" id="shippage">

<apex:form id="shipform">

<apex:outputpanel rendered="{!openPopup}">
   <script language="javascript" type="text/javascript">
      window.open("{!pr}","mywindow","menubar=0,resizable=1,width=750,height=350");
   </script>
</apex:outputpanel>
<apex:outputPanel rendered="{!openPopup1}">
   <script language="javascript" type="text/javascript">
      window.open("{!pr1}","mywindow1","menubar=0,resizable=1,width=750,height=350");
   </script>
</apex:outputPanel>
<apex:pageBlock title="Shipments Received/Departed"  id="shippageblock">

<div style="width:900px;margin:0 auto;" id="pagediv">
<span style="padding-left:30px;padding-right:10px">From </span><apex:inputfield value="{!fieldContainer.Start_Date__c}" id="startdt" style="padding-left:5px;padding-right:20px;"/>
<span style="padding-left:30px;padding-right:10px">To </span><apex:inputfield value="{!fieldContainer.End_Date__c}" id="enddt" style="padding-left:5px;padding-right:20px;"/>

<span style="padding-left:30px;padding-right:10px"><apex:commandButton action="{!printDeparted1}" value="Search" ReRender="dtshipdep,dtshiprec,shippageblock"></apex:commandButton></span>
</div>
 
<apex:commandButton action="{!saveDeparted}" onComplete="alert('Shipments Succesfully Departed');" value="Update Shipment Departed" ReRender="dtshipdep"></apex:commandButton> 

<apex:commandButton value="Print Outgoing Shipments" action="{!printDeparted}" ReRender="shipform" ></apex:commandButton>

<br/><br/>
<apex:pageBlockSection title="Outgoing Shipments" columns="1" >



 <apex:datatable value="{!LstOutgoingShipments}" columns="15"  var="inShip"  width="100%" cellpadding="2" cellspacing="2" columnsWidth="30px,50px,150px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px" rules="all" id="dtshipdep">
 
 <apex:column styleClass="columntext" headerClass="columntext">
 <apex:facet name="header" >Departed</apex:facet>
 <apex:InputField value="{!inShip.Shipment_Departed__c}"/>
 </apex:column>
 
  <apex:column styleClass="columntext" headerClass="columntext">
 <apex:facet name="header">Equipment</apex:facet>
 <apex:outputText value="{!inShip.Equipment__r.name}"/>
 </apex:column>
 
 <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Event        </apex:facet>
  <apex:outputText value="{!inShip.Event__r.name}"/>
 </apex:column>
 
  <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship from Location</apex:facet>
  <apex:outputText value="{!inShip.Ship_From_Location__r.name}"/>
 </apex:column>
   <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Est Dep Time</apex:facet>
  <apex:outputField value="{!inShip.Est_Departure_Time__c}"/>
 </apex:column>
 
    <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship To Location</apex:facet>
  <apex:outputText value="{!inShip.Ship_To_Location__r.name}"/>
 </apex:column>
 

      <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship To Vendor</apex:facet>
  <apex:outputText value="{!inShip.Ship_To_Vendor__r.name}"/>
 </apex:column>
       <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Est. Arrival Time</apex:facet>
  <apex:outputfield value="{!inShip.Estimated_Arrival_Time__c}"/>
 </apex:column>
        <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship To Instructions</apex:facet>
  <apex:outputText value="{!inShip.Ship_To_Instructions__c}"/>
 </apex:column>
 
         <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Carrier</apex:facet>
  <apex:outputText value="{!inShip.Shipping_Carrier__c}"/>
 </apex:column>
 
          <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Driver</apex:facet>
  <apex:outputText value="{!inShip.Shipping_Driver__c}"/>
 </apex:column>
 
           <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Driver Phone</apex:facet>
  <apex:outputText value="{!inShip.Shipping_Driver_Phone__c}"/>
 </apex:column>
 
            <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Post Event Instructions</apex:facet>
  <apex:outputText value="{!inShip.Post_Event_Instructions__c}"/>
 </apex:column>
 
             <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">No of Rolling Cases</apex:facet>
  <apex:outputText value="{!inShip.No_of_Rolling_Case__c}"/>
 </apex:column>
 
             <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">No of HD Cases</apex:facet>
  <apex:outputText value="{!inShip.No_of_HD_Case__c}"/>
 </apex:column>
 
 </apex:datatable>
              
</apex:pageBlockSection>
<br/><br/>
 
<apex:commandButton action="{!saveReceived}" value="Update Shipment Received" onComplete="alert('Shipments Successfully Received');" ></apex:commandButton>
<apex:commandButton value="Print Incoming Shipments" action="{!printReceived}" ReRender="shipform"></apex:commandButton>
<br/>
<apex:pageBlockSection title="Incoming Shipments" columns="1" >
 <apex:datatable value="{!LstIncomingShipments}" columns="14"  var="outShip"  width="100%" cellpadding="2" cellspacing="2" columnsWidth="30px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px,50px" rules="all" id="dtshiprec">
 
 <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Received</apex:facet>
 <apex:InputField value="{!outShip.Shipment_Received__c}"/>
 </apex:column>
 
  <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Equipment</apex:facet>
 <apex:outputText value="{!outShip.Equipment__r.name}"/>
 </apex:column>
 
 <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Event</apex:facet>
  <apex:outputText value="{!outShip.Event__r.name}"/>
 </apex:column>
 
  <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship from Location</apex:facet>
  <apex:outputText value="{!outShip.Ship_From_Location__r.name}"/>
 </apex:column>
   <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Est Dep Time</apex:facet>
  <apex:outputField value="{!outShip.Est_Departure_Time__c}"/>
 </apex:column>
 
     <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship To Location</apex:facet>
  <apex:outputText value="{!outShip.Ship_To_Location__r.name}"/>
 </apex:column>

       <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Est. Arrival Time</apex:facet>
  <apex:outputfield value="{!outShip.Estimated_Arrival_Time__c}"/>
 </apex:column>
        <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Ship To Instructions</apex:facet>
  <apex:outputText value="{!outShip.Ship_To_Instructions__c}"/>
 </apex:column>
 
         <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Carrier</apex:facet>
  <apex:outputText value="{!outShip.Shipping_Carrier__c}"/>
 </apex:column>
 
          <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Driver</apex:facet>
  <apex:outputText value="{!outShip.Shipping_Driver__c}"/>
 </apex:column>
 
           <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Driver Phone</apex:facet>
  <apex:outputText value="{!outShip.Shipping_Driver_Phone__c}"/>
 </apex:column>
 
            <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">Post Event Instructions</apex:facet>
  <apex:outputText value="{!outShip.Post_Event_Instructions__c}"/>
 </apex:column>
 
            <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">No Of Rolling Cases</apex:facet>
  <apex:outputText value="{!outShip.No_of_Rolling_Case__c}"/>
 </apex:column>
 
            <apex:column headerClass="columntext" styleClass="columntext">
 <apex:facet name="header">No Of HD Cases</apex:facet>
  <apex:outputText value="{!outShip.No_of_HD_Case__c}"/>
 </apex:column>
 
 </apex:datatable>
              
</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller which VF page which works correctly

public class ctrl_shipments {
    public List<Event_Equipment__c> LstOutgoingShipments= new List<Event_Equipment__c>();
    public List<Event_Equipment__c> LstIncomingShipments=new List<Event_Equipment__c>();
    public List<DummyTable__c> dt= new List<DummyTable__c>();
    public List<user> LstCurrentUserAccount= new List<user>();
    Id userid;
    public string url ;
    public PageReference pr{get;set;}
    public PageReference pr1{get;set;}
    public string urlRec ;
    public   boolean openPopup{get;set;}
    public   boolean openPopup1{get;set;}
    public datetime startdate {get; set;}
    public DummyTable__c fieldContainer {get; set;}
    
    
    public datetime enddate {get; set;}
        public date startdate1 {get; set;}
    
    public date enddate1 {get; set;}
         public List <DummyTable__c> getdt() {
        return dt;
    }
    
   
     public List <Event_Equipment__c> getLstOutgoingShipments() {
        return LstOutgoingShipments;
    }
    public List <Event_Equipment__c> getLstIncomingShipments() {
        return LstIncomingShipments;
    }
    public Pagereference  printDeparted()
    {
        openPopup=true;
        openPopup1=false;
         pr = Page.PrintShipDeparted;
        pr.setRedirect(true);
        pr.getParameters().put('Pstartdate',string.valueof(startdate1));
        pr.getParameters().put('Penddate', string.valueof(enddate1));
        
        return null;
        
    }
    public Pagereference  printReceived()
    {
        openPopup1=true;
        openPopup=false;
         pr1 = Page.printShipReceived;
        pr1.setRedirect(true);
        pr1.getParameters().put('Pstartdate',string.valueof(startdate1));
        pr1.getParameters().put('Penddate', string.valueof(enddate1));
        
        return null;
        
    }
    

    public void printDeparted1()
    {
        
        
        //if(fieldContainer.Start_Date__c!=null)
        startdate1=fieldContainer.Start_Date__c;
        system.debug('startdate1'+startdate1);
        
        //if(fieldcontainer.End_Date__c!=null)
        enddate1=fieldContainer.End_Date__c;
        system.debug('enddate1'+enddate1);
        system.debug('inside printdeparted1....after clicking search button');

        system.debug('startdate1'+startdate1);
        system.debug('url'+url);
        LoadData();
    }
    string CurrentUserAccount='';
    public ctrl_shipments()
    {
        openPopup=false;
        openPopup1=false;
        System.debug('inside constructor');
        fieldContainer=new DummyTable__c();
        date todays=date.today();
         datetime myDate = datetime.newInstance(2011, 06, 12);
         startdate=datetime.newInstance(2012, 01, 19, 09, 30, 2);
         enddate=datetime.newInstance(2012, 01, 19, 23, 30, 2);
         If (fieldContainer.Start_Date__c== null)
         {
            startdate1=todays;
         }else
         {
         startdate1=fieldContainer.Start_Date__c;
         }
         
         If (fieldContainer.End_Date__c== null)
         {
            enddate1=todays;
         }
         else
         {
         enddate1=fieldContainer.End_Date__c;
         }

         Loaddata();

        
    }
    
    public void LoadData()
    {
        userid = UserInfo.getUserId();

        LstCurrentUserAccount=[select id,Related_Account__c from user where id=:userid];
        If (LstCurrentUserAccount.size()>0)
         CurrentUserAccount=LstCurrentUserAccount[0].Related_Account__c;


        LstOutgoingShipments=[select id,
                            Equipment__r.name,
                            Event__r.name,
                            Event_Date__c,
                            Ship_From_Location__r.name,
                            Ship_From_Vendor__r.name,
                            Est_Departure_Time__c,
                            Ship_To_Location__r.name,
                            Ship_To_Vendor__r.name,
                            Estimated_Arrival_Time__c,
                            Ship_To_Instructions__c,
                            Shipping_Carrier__c,
                            Shipping_Driver__c,
                            No_of_Rolling_Case__c,
                            No_of_HD_Case__c,
                            Shipping_Driver_Phone__c,
                            Post_Event_Instructions__c, 
                            Shipment_Departed__c,
                            Shipment_Received__c from Event_Equipment__c 
                            where Ship_From_Vendor__c=:CurrentUserAccount and DAY_ONLY(Est_Departure_Time__c)>=:startdate1 and DAY_ONLY(Est_Departure_Time__c)<=:enddate1 ];
     
         LstIncomingShipments=[select id,
                            Equipment__r.name,
                            Event__r.name,
                            Event_Date__c,
                            Ship_From_Location__r.name,
                            Ship_From_Vendor__r.name,
                            Est_Departure_Time__c,
                            Ship_To_Location__r.name,
                            Ship_To_Vendor__r.name,
                            Estimated_Arrival_Time__c,
                            No_of_Rolling_Case__c,
                            No_of_HD_Case__c,                          
                            Ship_To_Instructions__c,
                            Shipping_Carrier__c,
                            Shipping_Driver__c,
                            Shipping_Driver_Phone__c,
                            Post_Event_Instructions__c, 
                            Shipment_Departed__c,
                            Shipment_Received__c from Event_Equipment__c 
                            where Ship_To_Vendor__c=:CurrentUserAccount and DAY_ONLY(Estimated_Arrival_Time__c)>=:startdate1 and DAY_ONLY(Estimated_Arrival_Time__c)<=:enddate1 ];
    }
    
    boolean UpdateMessage = false;
    
    public boolean getUpdateMessage ()
    { system.debug('++++++++++++++++++++++++++++ UpdateMessage in get  '+UpdateMessage   );
    return UpdateMessage; }
    
    public void saveDeparted()
    {
        update LstOutgoingShipments;
        UpdateMessage  = true;
        system.debug('++++++++++++++++++++++++++++ UpdateMessage in save  '+UpdateMessage   );
       // return UpdateMessage;
    }  
    
     public void setUpdateMessage ( boolean UpdateMessage)
    {this.UpdateMessage = UpdateMessage; }
    
    public void saveReceived()
    {
        update LstIncomingShipments;
    }
    
}

 

Niket SFNiket SF

Hello Prady,

Please check that object is having permission for Display only or It having both Edit and visible. This type of issues come when you have any visible permission for that object field.

 

 

Thanks 

Nik's

Skype Name : niket.chandane

prady-cmprady-cm

Nik,

 

The interesting thing is that, its only showing null for some records,  so i wouldnt think it would visiblility permission for that field.

But there is a difference in working and non working VF page is that one has a inputfield and the otherone uses output field. Thing to note here is that the field which is not visible in somerecords is outputfield in both pages.

Niket SFNiket SF

According to me it's should not happen there must be any sharing rules which are giving access to some record. Please check with that without sharing and with sharing Keyword in your class.

 

Thanks

Nik's

Skype name : Niket Chandane

 

This was selected as the best answer
prady-cmprady-cm

Nik,

 

You are the man....

It was sharing keyword which was causing this error..

 

Thanks

Niket SFNiket SF

You welcome 

Prady :)