I want to fetch Note Type field version history from SharePoint Hosted App page.
I have tried GetVertinCollection()
method /_vti_bin/lists.asmx
but unable to fetch item field version history from SharePoint Hosted App.
I want to fetch Note Type field version history from SharePoint Hosted App page.
I have tried GetVertinCollection()
method /_vti_bin/lists.asmx
but unable to fetch item field version history from SharePoint Hosted App.
If I understand your question correctly, you're trying to get all historic values of a multi-line text field.
The SPServices library makes this quite easy.
$scope.getFieldHistory = function (itemId, fieldName, field) {
$().SPServices({
operation: "GetList",
listName: "Your list name",
async: false,
completefunc: function (xData, Status) {
var xmlDoc = $.parseXML(xData.responseText);
$xml = $(xmlDoc);
var list = $xml.find("GetListResult > List");
var id = list.attr("ID");
$().SPServices({
operation: "GetVersionCollection",
strlistID: id,
strlistItemID: itemId,
strFieldName: fieldName,
completefunc: function (xData, Status) {
var xmlDoc = $.parseXML(xData.responseText);
$xml = $(xmlDoc);
field.history = [];
var values = $xml.find("Versions > Version").each(function () {
var version = {};
version.value = $(this).attr(fieldName);
var rawDate = moment($(this).attr("Modified")).local();
version.editDate = rawDate.format("MM/DD/YYYY hh:mm A");
var rawEditor = $(this).attr("Editor");
version.editor = rawEditor.split("#,#")[1];
field.history.push(version);
});
}
});
}
});
};
For getting item's version you do not need any extra hassle. When you request for some items to SP, it returns version along with other data. For example, you have made a GET request to the following URL
_api/web/lists/GetByTitle('List Name')/Items
Now in the response, find __metadata.etag
. The value of __metadata.etag
is your item's version.
{
"d": {
"results": [
{
"__metadata": {
"id": "cf7b1e7a-2103-428a-8e97-7e028ffc9e6a",
"uri": "https://xxx.sharepoint.com/_api/Web/Lists(guid'233ae45e-f581-4420-b069-b7a74d368b13')/Items(1)",
"etag": "\"6\"",
"type": "SP.Data.XXXListItem"
},
"Title": "Developer Team"
}
]
}
}