Guest User

Untitled

a guest
Jan 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <script type="text/javascript">
  2. var listItem;
  3. var list;
  4. var title;
  5. var clientContext;
  6. var item1;
  7. var value;
  8. var source;
  9. var weburl;
  10. var currentListGUID;
  11.  
  12. function getSetListItem()
  13. {
  14. source=document.URL;
  15. clientContext = SP.ClientContext.get_current();
  16. if (clientContext != undefined && clientContext != null)
  17. {
  18. weburl=_spPageContextInfo.webServerRelativeUrl;
  19. currentListGUID = SP.ListOperation.Selection.getSelectedList();
  20. if(currentListGUID === "undefined" || currentListGUID === null)
  21. {
  22. alert('Please select one row');
  23. }
  24. else{
  25. var webSite = clientContext.get_web();
  26. var ctx = GetCurrentCtx();
  27. title =ctx.ListTitle;
  28. list = webSite.get_lists().getByTitle(title);
  29. var selectedItems = SP.ListOperation.Selection.getSelectedItems(clientContext);
  30. if(Object.keys(selectedItems).length>1)
  31. {alert('Please select only one row');}
  32. else{
  33. for (var item in selectedItems)
  34. {
  35. item1=selectedItems[item].id;
  36. }
  37. listItem = list.getItemById(item1);
  38. clientContext.load(this.listItem);
  39. clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess),
  40. Function.createDelegate(this, this.OnLoadFailed));
  41. ShowDialog();
  42. }
  43. }
  44. }
  45. }
  46.  
  47. function OnLoadSuccess(sender, args)
  48. {
  49. value = this.listItem.get_item("FileLeafRef");
  50. }
  51.  
  52. function ShowDialog()
  53. {
  54. var options =
  55. {
  56. autoSize: true,
  57. allowMaximize: true,
  58. title: 'Version History',
  59. showClose: true,
  60. url:weburl+'/_layouts/15/Versions.aspx?list=' + currentListGUID + '&ID='+item1+'&Source='+weburl+'/Lists/'+title+'/AllItems.aspx',
  61. };
  62. SP.UI.ModalDialog.showModalDialog(options);
  63. }
  64. </script>
Add Comment
Please, Sign In to add comment