+ Start a Discussion
ValueText SMSValueText SMS 

with sharing not enforcing on FLS

My controler :

public with sharing class sharingtest1{
 public string datax{get;set;}
  public void runquery(){ 
    contact c=[select id,name,rsplus__DateTime_Field__c from contact        where id='sfid'];
    datax=json.serialize(c);
     system.debug(c+'KKKK');
  }
}

My page:
<apex:page controller="sharingtest1">
<apex:form >
<apex:outputText value="{!datax}"></apex:outputText>
<apex:commandButton value="call" action="{!runquery}"/>
</apex:form>
</apex:page>

Rsult for button click "call":

Id:,Name:Lauren Boyle,rsplus__DateTime_Field__c:2016-05-08T05:26:00.000+0000

My FLS (notmal salesforce licenec profile , where view all  and modefy all is false)
User-added image


Can any one help me why with sharing keyword is not enforcing on SOQL, I can see "dattime field" data in json. I am need to do manual sharing checking my using describe class?



 
JyothsnaJyothsna (Salesforce Developers) 
Hi Shiva,

I tried this scenario in my personal DE account its working properly.Please cors-check your steps with the below steps.

Go to Setup--->Administer--->Manage Users--->Users--->System Administrator---->Field-Level Security--->Contact object.

Please check the below screenshot

User-added image

Visualforce Page
 
<apex:page controller="Contact1Class">
  <apex:form >
  <apex:pageBlock >
  <apex:pageBlockTable value="{!conlst}" var="c">
  <apex:column >
  <apex:outputField value="{!c.LastName}"/>
  </apex:column>
  <apex:column >
  <apex:outputField value="{!c.Datetime__c}"/>
  </apex:column>
  </apex:pageBlockTable>
  </apex:pageBlock>
  </apex:form>
</apex:page>

Controller
 
public with sharing class Contact1Class {

    public List<Schema.Contact> conlst { get; set; }
    
    public Contact1Class(){
    
    conlst=new List<Schema.Contact>();
    conlst=[select Lastname,Datetime__c from contact limit 5];
    }
}

User-added image

In DE account ,we have 2 salesforce licenses.

Hope this helps you!
Regards,
Jyothsna