| | Stumble It! | Add to Mixx! | | diigo it | | Slashdot |

Friday, July 31, 2009

Hide/Remove "Workspace" from SharePoint Forms

One of the more popular posts on this blog has been my description on how to remove the "Workspace" option from SharePoint forms. For those that aren't familiar with this particular annoyance, think of it as SharePoint's appendix - not really useful, but can cause problems if it gets infected ... (that sounded better in my head).

Anyway, I've come up with a cleaner (cleverer!) way to accomplish this task! You'll still need to "pop the hood" on all of the forms that you want to remove the "Workspace" option from by using the "...Form.aspx?ToolPaneView=2" trick and add a Content Editor Web Part (CEWP) to the bottom of the page, but now you only have a very small bit of JavaScript to add to the CEWP.

And here it is:
<script type="text/javascript">
var trs = document.getElementsByTagName("TR");
for (var r in trs) {
var row = (trs[r].innerText || trs[r].textContent)+"";
if (row.match(/^Workspace/)) { trs[r].style.display = "none"; }
}
</script>
If you want to get experimental with this and try to remove other rows from your forms, you can do so by modifying the IF statement as follows:
...
if (row.match(/^Workspace/) || row.match(/^Row Title 1/) || row.match(/^Row Title 2/))
{ trs[r].style.display = "none"; }
}
</script>
NOTE: It's VERY important to include the carat (^). If you don't you'll kill your page. If this happens to you, simply hit the "Back" button & add the ^.

6 comments:

Colin said...

Thank you!

utilityboy said...
This post has been removed by the author.
Shilpa said...

Thanks a ton!

Shilpa said...
This post has been removed by the author.
globeadue said...

Had some fun trying to get this to work on SP 2010 foundation..
The first example wouldn't work, but merging the second examples "if" code in got it working.
Some notes / bugs...
Doesn't work with firefox.
Making edits to the view broke it, had to reedit and apply the code again.
I found it best to follow these steps...
edit the edit form, add the cewp add the code to the cewp then take any web part and do edit webpart so that you get the right panel properties box for the web part. just click apply. That seems to get the page to read everything again, hitting f5 to refresh was loosing my changes that i thought wer saved.

Ben said...

Hi globadue,

Unfortunately I haven't been able to get my hands on a copy of SP2010 to do any development just yet so I can't say with any authority if this code will work on it.

-Ben