我正在在线上过滤一个查找列,但是如果我在浏览器上检查并且过滤不起作用,我会继续出现错误。
我使用jquery.spservices.spgetcurrentuser获取登录用户详细信息。然后查询要过滤并获取列表活动计划。
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script
src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js"></script>
<script type="text/javascript">
let custom = {}
custom.myQuery = jQuery;
console.log(custom)
console.log($().SPServices.SPGetCurrentUser({
fieldNames: ["ID", "Name", "Title", "Email","DepartMent", "JobTitle",
"FirstName", "LastName", "UserName", "SIP Address"],
debug: false
}));
var userId = $().SPServices.SPGetCurrentUser({
fieldName: "ID",
debug: false
})
_spBodyOnLoadFunctionNames.push("loadSP")
function loadSP() {
var query = `<Query><Where><And><Eq><FieldRef Name='AssignedTo'
LookupId='TRUE'/><Value Type='Integer'>${userId}</Value></Eq><Eq>
<FieldRef Name='Status' LookupId='TRUE'/><Value
Type='Text'>Approved</Value></Eq></And></Where></Query>`;
custom.myQuery().SPServices({
operation: "GetListItems",
async: false,
listName: "Activity Plan",
CAMLQuery: query,
//CAMLQueryOptions: "<QueryOptions><ViewAttributes
Scope='RecursiveAll' IncludeRootFolder='True' /></QueryOptions>",
CAMLViewFields: `<ViewFields>
<FieldRef Name='Deliverable' />
<FieldRef Name='Task Status' />
<FieldRef Name='ID' />
</ViewFields>`,
completefunc: function (xData, Status) {
var newSites = "(none)";
var ID = "0";
console.log(xData)
$(xData.responseXML).find("z\:row, row").each(function () {
var DeliverableLookup = $(this).attr("Deliverable");
var owId = $(this).attr("ID");
if (DeliverableLookup != '') {
var newValue = DeliverableLookup;
if (newSites.indexOf(newValue) == -1) {
newSites = newSites + "|" + newValue;
ID += '| ' + owId;
}
}
});
updateValues(newSites, ID);
}
});
}
function getField(fieldType,fieldTitle) {
var docTags = document.getElementsByTagName(fieldType);
for (var i=0; i < docTags.length; i++) {
if (docTags[i].title == fieldTitle) {
return docTags[i];
}
}
return false;
}
function updateValues(newSites, ID) {
lookupFieldText = getField('select','My Planned Tasks');
//lookupFieldId = document.getElementById(lookupFieldText.id);
$(lookupFieldText).empty();
let arrSites = newSites.split('|');
let arrId = ID.split('|');
for (let i = 0; i < arrSites.length; i++){
$(lookupFieldText).append(`<option id='${arrId[i]}'
value='${arrSites[i]}'> ${arrSites[i]} </option>`)
}
//lookupFieldText.choices = newSites;
}
function CustomAction(){
console.log("done loading")
}
</script>
我希望"查找"列我计划的任务只显示我创建的可交付成果并获得状态批准,但它正在返回所有任务。
检查您的控制台记录的数据,并查看返回的内容,如果没有返回,请检查您的状态是否为真,如果不是,则您的查询是错误的。.检查查询中的空格。<<<<<<<<<<<<<<<<<<<<