ID’s are a convenient, often short, way to uniquely refer to something. Unless you’re the Tax man who seems to believe he can’t get through his day without giving me, thats just one person, 7 unique id’s – presumably one for each extremity that he would like a piece off…
I digress… ID’s – SharePoint uses an ID for each item in a list and sometimes its handy to know them “Ere Bob – have you done task 1234 yet?”
You can easily add them to the list view (Modify this View then find the ID column, click display)
But what about if you want to see this on the View and Edit forms? (You can’t see it on the New form as it doesn’t get an ID assigned until you’ve created it)
Not so fast though young Jedi – before embarking on any of these hacks you should understand the pros and cons and this excellent article is a good place to start – jQuery : The SharePoint band aid.
Right now you’re back (you did read it right?) and understand what you’re getting into.
Open up the View page for any of your list items and add ToolPaneView=2 onto the end of the URL to open up the page in edit mode.
Note – if you already have a query string (&ID=xzx…) on the end of the url then you need to use &ToolPaneView=2 and if you don’t its ?ToolPaneView=2 e.g.
Next add a Content Editor Web Part (CEWP) to the page and put the following code into it using the Edit Source button.
- This has been tested in WSS3 (SharePoint 2007) and SharePoint 2010 Foundation – I would expect it to also work in MOSS/SharePoint 2010 Server.
- The method for adding a CEWP to the page in SharePoint 2010 is slightly different.
- When looking for references I found that Christophe beat me to it by about, ohh a year and a half and his version can be found here.
He doesn’t use jQuery so there is a little more code to write. If you’re just doing this or can’t use jQuery on your site (e.g. no network access) then you may be better off with his version. If you want to do other thigns on the form you may be better with the jQuery version above.