简体   繁体   English

SOQL查询不返回Visualforce页面上确实存在的行

[英]SOQL query not returning rows that do exist on visualforce page

SOQL query not returning rows on visualforce page that do exist in object I am having issues retrieving records which exist from an object via a SOQL query on a visualforce page SOQL查询未返回对象中确实存在的visualforce页面上的行我在通过Visualforce页面上的SOQL查询检索对象中存在的记录时遇到问题

How do I know they exist? 我怎么知道它们的存在? I have used force explorer and workbench and the following returns a record 我已经使用了力资源管理器和工作台,以下返回记录

SELECT Code__c FROM External_membership_label__c WHERE Code__c = '3'

OK, so the visualforce page does not return the record above, with the code below (few lines from code) 好的,因此visualforce页面不会返回上面的记录以及下面的代码(代码中的几行)

  public String gvlLCCODE {get;set;}

  if(gvlLCCODE != null || gvlLCCODE != ''){

        List<External_membership_label__c> exisitingGVLcodes = [SELECT Code__c FROM External_membership_label__c WHERE Code__c = :gvlLCCODE];

        if (exisitingGVLcodes.Size() > 0){
            //blahh blahh
        }
}

Any suggestions? 有什么建议么? I have debug telling me 'gvlLCCODE' has a value that exists in the object. 我进行了调试,告诉我'gvlLCCODE'具有对象中存在的值。 Also, if I change the SOQL to say, for example, return the current user from the users table, it returns a record and then enters the IF statement. 另外,例如,如果我更改SOQL来表示,例如,从users表返回当前用户,它将返回一条记录,然后输入IF语句。

I think its a security issue I have missed. 我认为这是我错过的安全问题。 But I have also checked these. 但是我也检查了这些。

Thank you 谢谢

well, for one, in your IF statement you probably want to use &&, instead of ||. 好吧,其中之一,在您的IF语句中,您可能要使用&&而不是||。

Are you having the problem with the test method? 您在测试方法上有问题吗? if so, then it's because that method doesn't have access to the existing records by default. 如果是这样,那是因为默认情况下该方法无权访问现有记录。

First of all you should listen to Kirill about the &&, both condtions should be met, not just one. 首先,您应该听听Kirill关于&&的知识,应该满足两个条件,而不仅仅是一个。 Likewise, the || 同样, || is meaningless, formula (a!=b)|(a!=c) is always true for any a when b!=c as is the case here 是没有意义的,当b!=c时,公式(a!=b)|(a!=c)对于任何a始终为真

Second, it sounds as you definitely have a security issue here. 第二,听起来您这里肯定有安全问题。 To verify change extension's declaration from with sharing to without sharing and run. 验证变更扩展的声明从with sharingwithout sharing并运行。 If you get the row you have sharing security issues with the row. 如果获得该行,则与该行存在共享安全性问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM