【发布时间】:2015-11-26 01:35:04
【问题描述】:
我在 Salesforce.com 的 visualforce 页面中使用。出于演示目的,我使用了
中显示的示例文档中的以下代码 sn-phttp://docs.releasenotes.salesforce.com/en-us/spring14/release-notes/rn_vf_remote_objects.htm
在我的代码 sn-p 中,我有一个“Where”子句,我试图在其中使用 3 个字段进行过滤。我的要求是记录必须符合条件 A 或条件 B 或条件 C。
代码示例
<apex:page >
<!-- Remote Objects definition to set accessible sObjects and fields -->
<apex:remoteObjects >
<apex:remoteObjectModel name="Group_Donor__c" jsShorthand="Groupdonor"
fields="Name,Id">
<apex:remoteObjectField name="State__c" jsShorthand="State"/>
<apex:remoteObjectField name="Org_Phone__c" jsShorthand="Phone"/>
<apex:remoteObjectField name="Billing_Type__c" jsShorthand="billingtype"/>
</apex:remoteObjectModel>
</apex:remoteObjects>
<!-- JavaScript to make Remote Objects calls -->
<script>
var fetchWarehouses = function(){
// Create a new Remote Object
var wh = new SObjectModel.Groupdonor();
// Use the Remote Object to query for 10 warehouse records
wh.retrieve({
where: {
or: {
Name : {like:"%Helloworld%"}, // Error
State: {like:"%chennai%"},
//Phone: {like:"%098765432344%"},
billingtype: {like:"%Credit Card%"}
}
},
limit: 10 ,
}, function(err, records, event){
if(err) {
alert(err.message);
}
else {
var ul = document.getElementById("warehousesList");
records.forEach(function(record) {
// Build the text for a warehouse line item
var whText = record.get("Name");
whText += " -- ";
whText += record.get("Phone");
whText += " -- ";
whText += record.get("billingtype");
// Add the line item to the warehouses list
var li = document.createElement("li");
li.appendChild(document.createTextNode(whText));
ul.appendChild(li);
});
}
});
};
</script>
<h1>Retrieve Group Donors via Remote Objects</h1>
<p>Warehouses:</p>
<ul id="warehousesList">
</ul>
<button onclick="fetchWarehouses()">Retrieve Group Donors</button>
</apex:page>
当我执行此代码时,我收到以下错误。
错误信息:
Invalid criteria specified for retreival. ValidationError [code=11, message=Data does not match any schemas from "oneOf" path=/where, schemaKey=null]
此问题仅在以下情况下发生。
- 当我在 OR 条件中使用标准字段(如名称)时。 (甚至 2 或 1 个过滤器)
- 当我在 OR 条件中使用超过 3 个自定义字段时(超过 2 个查询过滤器)
但是,当我只使用 RemoteObjectModel 中提到的任何 2 个自定义字段作为过滤器时,我得到了预期的结果。
请让我知道我在这里缺少什么。如果我在或条件下使用了超过 2 个过滤器,我该如何实现?在远程对象中正确使用“或”吗?有没有人遇到过这个问题。如果是这样,请给我一些指示。
提前致谢。
【问题讨论】:
标签: salesforce visualforce apex force.com remoteobject