我正在使用Salesforce.com的visualforce頁面。爲了演示,我已經使用給出的示例文檔下面的代碼片段在Visualforce RemoteObjectModels使用「OR」查詢篩選
http://docs.releasenotes.salesforce.com/en-us/spring14/release-notes/rn_vf_remote_objects.htm
在我的代碼片段我有我正努力用3個字段篩選「去哪兒」的條款。我的要求是記錄必須在i執行此代碼我得到以下錯誤的標準的或標準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條件(超過2查詢過濾器)的使用3個以上的自定義字段
但是當我使用只是在RemoteObjectModel提及作爲過濾器的任何2個的自定義字段,我得到了預期的結果。
請讓我知道我在這裏錯過了什麼。如果我使用超過2個過濾器或條件,我該如何實現它?在遠程對象中使用'OR'是否恰當?任何人都會遇到這個問題。如果這麼友好地給我一些指點。
在此先感謝。
看起來我們必須忍受這個!感謝您的時間 。 – Sumuga
是的,我有點失望地發現這個限制!我想有一些解決方法,但仍然不是很好。我已經必須實現一個遞歸記錄檢索系統來解決100個記錄的限制,所以這隻會變得更糟。希望他們能在某個時候更新API。 –