Last active
August 29, 2015 14:02
-
-
Save premchandpl/664899abc1ecb00e5ede to your computer and use it in GitHub Desktop.
Complete Code Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| that.getData = function (listName, xmlQuery, contentType, onGetSuccess) { | |
| var objClientCtx = new SP.ClientContext.get_current(); | |
| if (objClientCtx) { | |
| var oWeb = objClientCtx.get_web(); | |
| var oList = oWeb.get_lists().getByTitle(listName); | |
| var query = new SP.CamlQuery(); | |
| query.set_viewXml(xmlQuery); | |
| var objlistItems = oList.getItems(query); | |
| objClientCtx.load(objlistItems); | |
| objClientCtx.executeQueryAsync(function (sender, args) { | |
| that.DataSet = []; | |
| var objlistEnumerator = objlistItems.getEnumerator(); | |
| while (objlistEnumerator.moveNext()) { | |
| var objListItem = objlistEnumerator.get_current(); | |
| var id = objListItem.get_item('ID'); | |
| var filePath = 'your site collection/Lists/your list/'+id+'_.000' | |
| var web = objClientCtx.get_web(); | |
| var listItemInfo = web.getFileByServerRelativeUrl(filePath) | |
| var listItemFields = listItemInfo.get_listItemAllFields() | |
| objClientCtx.load(web); | |
| objClientCtx.load(listItemInfo); | |
| objClientCtx.load(listItemFields); | |
| //objClientCtx.load(versions1); | |
| objClientCtx.executeQueryAsync( | |
| function (sender, args) { | |
| var fileVersions = listItemInfo.get_versions(); | |
| objClientCtx.load(fileVersions); | |
| objClientCtx.executeQueryAsync( | |
| function (sender, args) { | |
| var objlistVersionEnumerator = fileVersions.getEnumerator(); | |
| while (objlistVersionEnumerator.moveNext()) { | |
| var objCurrentListItemVersion = objlistVersionEnumerator.get_current(); | |
| console.log(objCurrentListItemVersion.get_url()); | |
| } | |
| }, | |
| function (sender, args) {console.log('Error');} | |
| ) | |
| }, | |
| function (sender, args){ | |
| console.log('error') | |
| }); | |
| } | |
| onGetSuccess(that.DataSet); | |
| }, function (sender, args) { | |
| that._onGetFail(sender, args); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment