1

I created a web part with all items of different lists, I also added a image button in front of each item, now on click I want to see a dialog box opening with version history of that item.

I think it must be possible, don't want to re-invent the wheel and start doing it from scratch.

2 Answers 2

2

You can use Out the Box Version History Page for displaying this information.

The URL to this page is

http://siteurl/_layouts/15/Versions.aspx?list={LISTID}&ID=ITEMID&IsDlg=1

You need to replace LISTID with your list guid. It will be of form E3B0E0D6-7053-4CA0-9F24-CC99DE0C0AB1

Also you need to pass the Id of the item - Replace ITEMID with list item id.

For displaying version history as a dialog you can use below JavaScript

var options =
{
    title: 'Version History',
    url: 'URL'
}

SP.UI.ModalDialog.showModalDialog(options);
2
  • thank you, is there any work around for not using list id, off course i can get it using code but just wondering, i am going to test your code soon Commented May 18, 2015 at 12:21
  • Versions.aspx is a generic page. So that page needs to know which List the item belongs to. List ID will be Unique across site, while item Id is not unique across site. Commented May 18, 2015 at 12:24
0

How about adding a link to your button which takes the user to the Display Form (DispForm.aspx) for the Item? From the Display Form, they're then able to click on the version history button in the ribbon.

All you need to know is where the item is located, then you can find the relevant Display Form and pass it the ID of the Item.

A typical Display Form may be located at an address like http://siteCollection/subSite/library/Forms/DispForm.aspx

If you know the Item ID, you can add it on like so http://siteCollection/subSite/library/Forms/DispForm.aspx?ID=1234 then your link takes you to the Display Form showing the particular Item with version history available.

See SP.List.defaultDisplayFormUrl Property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.