Is there is a way to retrieve the List Item Id (ID) that you are currently viewing (Display.aspx from) in javascript.

I have searched through ctx and the _spPageContextInfo but have not found any solutions. Most the mentions online speak of getting the selected item in the AllItems.aspx view but I am interested in getting it in the Display Form.


You can do this with javascript and JSRequest.

The ID should be passed in via the URL, (ie. 'DispForme.aspx?Id=11'), then use the below code to retrieve the '11'..

var itemId = JSRequest.QueryString["ID"];
  • I believe he is asking about List Id and not Item Id. – Paul Strupeikis Jun 25 '15 at 8:02
  • I made a typo, you were correct in your assumption Simon. – Mido Jun 25 '15 at 8:19

ItemID, just use the URL:

var itemIdINT = GetUrlKeyValue("ID", false, location.href);

ListId in the SP forms there are a couple of fields where you can extract the List GUID via jquery... e.g.:

var listIdGUID = $('[id^=_ListSchemaVersion_]').attr('id').toString().match(new RegExp(/\{(.*?)\}/))[1];

You may use something like this:

function getQS(key) {
  var regex=new RegExp('[\\?&]'+key+'=([^&#]*)');
  var qs=regex.exec(window.location.href);
  return qs[1];

var itemID = getQS('ID');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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