You need to sign in to do that
Don't have an account?
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 ]; } }
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
Continued from above post.
This VF page displays values correctly
Controller which VF page which works correctly
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
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.
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
Nik,
You are the man....
It was sharing keyword which was causing this error..
Thanks
You welcome
Prady :)