|
There've been times where I've created list and wanted to add the ID number to the display form. I never really found away until now. I read a blog from PathtoSharePoint.com that explained it a little bit.
The steps below are much clear and easier to understand. Hope this helps.
- Go to the list that contains your items.
- Click on the item - now you should be in the display form
- Go the url - the url should looks something like: http://domain/sites/test/Lists/New%Test%20Form/DispForm.aspx?ID=267.....
- Highlight - from http to aspx and delete the rest. Your URL should now look like this
- http://domain/sites/test/ Lists/New%Test%20Form/DispForm.aspx
- Now add ?ToolPaneView=2 to the URL to take you to the edit mode. Your URL should now look like this" http://domain/sites/test/ Lists/New%Test%20Form/DispForm.aspx?ToolPaneView=2
- Click Go
- You should now be in the edit mode for the display form
- Click on Add a Web Part
- Under Miscellaneous - check Content Editor Web Part
- Click Add
- In the Content Editor Web Part
- Click Open the tool pane
- The add the following scripts - I've copied from Path to SharePoint article
- To view the ID in the first row - copy the code below:
<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>
To view the ID in the last row - past this code:
<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.appendChild(IdRow);
}
_spBodyOnLoadFunctionNames.push("DisplayItemID");
</script>
-
- Click Ok
- Click the plus + sign next to Layout
- Click Hidden
- Go back to the List
- Click an item
- And you should see the ID in the display form.
Add this page to your favorite Social Bookmarking websites
|
Comments
RSS feed for comments to this post.