Hi,
To get version of the SharePoint list items; there are two option in JavaScript
To get version of the SharePoint list items; there are two option in JavaScript
- SPServices
$().SPServices({
operation: "GetVersionCollection",
async: false,
strlistID: "Deviations",
strlistItemID: DID,
strFieldName: "PreventionDescription",
completefunc: function (xData, Status) {
// alert(xData.responseXML.xml)
$(xData.responseText).find("Version").each(function () {
preventiveListTemp.push({
"Description": $(this).attr("PreventionDescription"),
"Editor": $(this).attr("Editor").split(",#")[4],
"Modified": $(this).attr("Modified"),
"Image": "/_layouts/15/userphoto.aspx?size=S&accountname=" + $(this).attr("Editor").split(",#")[3].toLowerCase().replace("@", "%40")
});
});
}
});
operation: "GetVersionCollection",
async: false,
strlistID: "Deviations",
strlistItemID: DID,
strFieldName: "PreventionDescription",
completefunc: function (xData, Status) {
// alert(xData.responseXML.xml)
$(xData.responseText).find("Version").each(function () {
preventiveListTemp.push({
"Description": $(this).attr("PreventionDescription"),
"Editor": $(this).attr("Editor").split(",#")[4],
"Modified": $(this).attr("Modified"),
"Image": "/_layouts/15/userphoto.aspx?size=S&accountname=" + $(this).attr("Editor").split(",#")[3].toLowerCase().replace("@", "%40")
});
});
}
});
- ECMA
var clientContext = new SP.ClientContext;
//var oList = clientContext.get_web().get_lists().getByTitle('Deviations');
var web = clientContext.get_web();
var listItemInfo = web.getFileByServerRelativeUrl(filePath);
var listItemFields = listItemInfo.get_listItemAllFields();
clientContext.load(web);
clientContext.load(listItemInfo);
clientContext.load(listItemFields);
clientContext.executeQueryAsync(function (sender, args) {
var fileVersions = listItemInfo.get_versions();
clientContext.load(fileVersions);
clientContext.executeQueryAsync(function (sender, args) {
var fieldEnumerator = fileVersions.getEnumerator();
while (fieldEnumerator.moveNext()) {
var oListItemVersion = fieldEnumerator.get_current();
// preventiveListTemp.push({
// });
}
}, onQueryFailed);
}, onQueryFailed);