1

I have a force.com site, it has a visualforce page with a controller that is doing a very simple SOQL query to the database, which for some reason it's not returning any records.

Here's what I've covered: read access to account and contact objects; removed the "Where" clause from my Select and it's still not returning any records at all; also, I've tested the page in SF an it works fine... anyone know something I'm missing?!

Here is the query: 
list <Contact> sfContacts = [Select Id, FirstName, LastName, Email, AccountId, Account.Name, Account.Domain__c 
                               From Contact
                              Where Email =: myUser.myEmail
                                And Name like :pattern];

Thanks! eclf

  • to which profile you have given the read access to accounts / contacts ? also can you share ur SOQL query ? – Vamsi Krishna Sep 1 '14 at 10:20
  • Is your org wide default set to at least read? Does the guest user have read on Account/Contacts and the fields the SOQL is using/returning? Can you post the controller please? – Girbot Sep 1 '14 at 10:21
  • Hi! Yes I have given read access to accounts an contacts to the guest profile of my site, as well as the fields of these objects present in the query. I've put the query in the post. Many thanks! – eclf Sep 1 '14 at 10:50
  • can you run debug logs for your guest user and check the values of myUser.myEmail and pattern? – Richard Durrant Sep 1 '14 at 11:12
  • 1
    @eclf In that case change your controller class to WITHOUT SHARING. – PepeFloyd Sep 1 '14 at 11:45
2

Your class must use the WITHOUT SHARING keyword, this way, sharing settings won't be enforced. Notice that this must be used carefully and is not usually recommended unless necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.