我正在开发 SharePoint 托管应用程序来计算来自同一网站集下多个列表的值。我必须查找名称相似的列表。
例如:根站点:
/dev
子网站:
/dev/site1
/dev/site2
站点 1 和站点 2 都有名为“时间表”的列表。
考虑用户 1 和用户 2。每个用户都可以访问两个子站点。他们更新了两个站点上的时间表。
我需要的是从站点 1 和站点 2 计算时间表列表的字段 (loggedhours) 值,然后添加它,然后将其存储到根站点列表(单独的列表)。
此外,我必须仅根据用户过滤值。
例如:在 site1 > timesheet - 我要计算当前用户创建的项目,在 Site2 > timesheet - 计算当前用户创建的项目并将其存储到根站点。
我正在使用 caml 查询来检索值。但我不知道如何通过caml查询根据当前用户进行过滤。
我的代码
var TimesheetList01 = web01.get_lists().getByTitle('Timesheet');
var camlQuery01 = new SP.CamlQuery();
camlQuery01.set_viewXml("<View><Query><Where></Where></Query></View>");
this.collListItem01 = TimesheetList01.getItems(camlQuery01);
currentcontext01.load(collListItem01, 'Include(Id,LoggedHours)');
currentcontext01.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args) {
var mysum01 = 0;
var myloggedHours01 = 0;
var listItemInfo01 = '';
var listItemEnumerator011 = collListItem01.getEnumerator();
while (listItemEnumerator011.moveNext()) {
var oListItem01 = listItemEnumerator011.get_current();
myloggedHours01 = oListItem01.get_item('LoggedHours');
mysum01 = mysum01 + myloggedHours01;`
请帮忙。
谢谢,阿伦