admin管理员组文章数量:1418665
I cannot find a working solution to set a SharePoint 2013 list date using SPServices. I have done this multiple times for other column types, but I can't figure out the right format for dates. Here's what I'm doing:
var testdate = "2016-01-01 00:00:00";
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 4,
valuepairs: [["Due Date", testdate]],
pletefunc: function (xData, Status) {
}
});
I have also tried it with these test values, but nothing changes on my site:
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";
Please let me know if there's another date format I should try, or if you see anything else wrong with this code. It works when I point to one of my text fields, so I'm pretty sure it's just the date format that's messing things up.
I cannot find a working solution to set a SharePoint 2013 list date using SPServices. I have done this multiple times for other column types, but I can't figure out the right format for dates. Here's what I'm doing:
var testdate = "2016-01-01 00:00:00";
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 4,
valuepairs: [["Due Date", testdate]],
pletefunc: function (xData, Status) {
}
});
I have also tried it with these test values, but nothing changes on my site:
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";
Please let me know if there's another date format I should try, or if you see anything else wrong with this code. It works when I point to one of my text fields, so I'm pretty sure it's just the date format that's messing things up.
Share Improve this question edited Sep 17, 2015 at 17:56 greenbellpepper asked Sep 17, 2015 at 17:37 greenbellpeppergreenbellpepper 4222 gold badges8 silver badges14 bronze badges1 Answer
Reset to default 3UpdateListItems
operation expects date string to be provided in ISO 8601 format, for example:
var dueDateVal = new Date('2016-01-01 6:00:00').toISOString();
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Requests",
ID: 1,
valuepairs: [["DueDate", dueDateVal]],
pletefunc: function (xData, Status) {
console.log('List items has been updated');
}
});
In addition, make sure the proper name of Due Date
column is specified. UpdateListItems
operation expects an array of column StaticNames and values have to be specified for valuepairs
.
If column named Due Date
has been created via UI, then Due_x0020_Date
static name will be generated and the operation for setting its value the should be specified like this:
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]],
pletefunc: function (xData, Status) {
console.log('List items has been updated');
}
});
本文标签: javascriptUse SPServices UpdateListItems to set date in SharePoint 2013Stack Overflow
版权声明:本文标题:javascript - Use SPServices UpdateListItems to set date in SharePoint 2013 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745287492a2651586.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论