使用 SPServices UpdateListItems 在 SharePoint 2013 中设置日期
Use SPServices UpdateListItems to set date in SharePoint 2013
我找不到使用 SPServices 设置 SharePoint 2013 列表日期的有效解决方案。我已经为其他列类型多次执行此操作,但我无法找出正确的日期格式。这是我正在做的事情:
var testdate = "2016-01-01 00:00:00";
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 4,
valuepairs: [["Due Date", testdate]],
completefunc: function (xData, Status) {
}
});
我也尝试过使用这些测试值,但我的网站上没有任何变化:
var testdate = "2016-1-1 0:0:0";
var testdate = "2016-01-01T00:00:00Z";
var testdate = "2016-1-1T0:0:0Z";
var testdate = "2016-01-01T00:00:00";
var testdate = "2016-1-1T0:0:0";
如果我应该尝试另一种日期格式,或者如果您发现此代码有任何其他问题,请告诉我。当我指向我的文本字段之一时它会起作用,所以我很确定只是日期格式搞砸了。
UpdateListItems
操作需要在 ISO 8601 format 中提供日期字符串,例如:
var dueDateVal = new Date('2016-01-01 6:00:00').toISOString();
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 1,
valuepairs: [["DueDate", dueDateVal]],
completefunc: function (xData, Status) {
console.log('List items has been updated');
}
});
此外,请确保指定了 Due Date
列的 专有名称 。 UpdateListItems
操作需要一个包含列 StaticNames 的数组,并且必须为 valuepairs
指定值。
如果已通过 UI 创建了名为 Due Date
的列,则将生成 Due_x0020_Date
静态名称,设置其值的操作应如下指定:
var dueDateVal = new Date('2016-01-01 6:00:00').toISOString();
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 1,
valuepairs: [["Due_x0020_Date", dueDateVal]],
completefunc: function (xData, Status) {
console.log('List items has been updated');
}
});
我找不到使用 SPServices 设置 SharePoint 2013 列表日期的有效解决方案。我已经为其他列类型多次执行此操作,但我无法找出正确的日期格式。这是我正在做的事情:
var testdate = "2016-01-01 00:00:00";
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 4,
valuepairs: [["Due Date", testdate]],
completefunc: function (xData, Status) {
}
});
我也尝试过使用这些测试值,但我的网站上没有任何变化:
var testdate = "2016-1-1 0:0:0";
var testdate = "2016-01-01T00:00:00Z";
var testdate = "2016-1-1T0:0:0Z";
var testdate = "2016-01-01T00:00:00";
var testdate = "2016-1-1T0:0:0";
如果我应该尝试另一种日期格式,或者如果您发现此代码有任何其他问题,请告诉我。当我指向我的文本字段之一时它会起作用,所以我很确定只是日期格式搞砸了。
UpdateListItems
操作需要在 ISO 8601 format 中提供日期字符串,例如:
var dueDateVal = new Date('2016-01-01 6:00:00').toISOString();
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 1,
valuepairs: [["DueDate", dueDateVal]],
completefunc: function (xData, Status) {
console.log('List items has been updated');
}
});
此外,请确保指定了 Due Date
列的 专有名称 。 UpdateListItems
操作需要一个包含列 StaticNames 的数组,并且必须为 valuepairs
指定值。
如果已通过 UI 创建了名为 Due Date
的列,则将生成 Due_x0020_Date
静态名称,设置其值的操作应如下指定:
var dueDateVal = new Date('2016-01-01 6:00:00').toISOString();
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 1,
valuepairs: [["Due_x0020_Date", dueDateVal]],
completefunc: function (xData, Status) {
console.log('List items has been updated');
}
});