Display a List item ID at the top of the List Item Window in SharePoint 2010.

This is useful when you need to display the List Item ID at the top of the List Item window in SharePoint 2010.

Thank you to Christophe@PathToSharePoint.com for the javascript code only to display the List Item ID.

  • Open the List
  • Hit the List tab
  • Click the Form Web Parts dropdownlist
  • Choose “Default Display Form”
  • At the top of the Page – Insert Tab, Click the Web Part button to add a new Content Editor web part.
  • From Categories choose “Media and Content” > “Content Editor” and add it to the main section of the page
  • Click the “Click here to add content” and then click the HTML button in the Ribbon to bring up the Edit source code window.
  • In the window add the following code to display the Item ID at the top of the list item window.<script type=”text/javascript”>
    //
    // Item ID in DispForm.aspx and EditForm.aspx
    // Feedback and questions: Christophe@PathToSharePoint.com
    //
    function DisplayItemID()
    {
    var regex = new RegExp(“[\\?&]”+”ID”+”=([^&#]*)”);
    var qs = regex.exec(window.location.href);
    var TD1 = document.createElement(“TD”);
    TD1.className = “ms-formlabel”;
    TD1.innerHTML = “<h3 class=’ms-standardheader’>Issue ID</h3>”;
    var TD2 = document.createElement(“TD”);
    TD2.className = “ms-formbody”;
    TD2.innerHTML = qs[1];
    var IdRow = document.createElement(“TR”);
    IdRow.appendChild(TD1);
    IdRow.appendChild(TD2);
    var ItemBody =   GetSelectedElement(document.getElementById(“idAttachmentsRow”),”TABLE”).getElementsByTagName(“TBODY”)[0];
    ItemBody.insertBefore(IdRow,ItemBody.firstChild);
    }
    _spBodyOnLoadFunctionNames.push(“DisplayItemID”);
    </script>
  • Ignore any Warnings! Next hit the Page tab at the top of the page and view the list item. Done!

 

Any questions please just ask.

Derek Halstead is a SharePoint consultant as well as the founder and principal of CertifiedSolutionsAustralia.com and CoolWriteups.com. He has 16 years of experience in the IT industry, with over ten years focused on Microsoft SharePoint. He can be reached by using the Contact Me link in the top menu.
Back to Top