Here's how to do it:
- Open the "NewForm.aspx?ToolPaneView=2", "EditForm.aspx?ToolPaneView=2", and "DispForm.aspx?ToolPaneView=2" pages for the calendar you want to work on in your browser.
- Add a "Content Editor Web Part" (CEWP) BELOW the form fields.
- Click on the "open the tool pane" link in the CEWP and click the "Source Editor..." button.
- Paste this code into the CEWP:
<script type="text/javascript">
var theRows = document.getElementsByTagName("TR");
var r = 0;
var strTitle = "";
while (r < theRows.length)
{ try
{ strTitle = theRows[r].innerText || theRows[r].textContent;
strTitle = strTitle.replace(/\n|\r|\t|\^ /g,"");
if (strTitle.search("Workspace") == 0)
{ theRows[r].style.display = "none"; }
}
catch(err){}
r+=1;
}
</script> - Save and repeat for the remaining "*Form.aspx" pages and your users won't be hassled with the "Workspace" option any more.
Update! - 20 March 2009
I've put together a short step-by-step presentation to help explain the steps involved with installing this solution.If the text is too small in this presentation, you can view the full show here.


34 comments:
Thanks for the tip. I used it to remove workspaces from an internal calendar that never needed them. It just confused users, but no longer...thanks to you!
Hi Ryan, I'm glad that the code was useful for you!
I have since cleaned it up a bit and made it cross-browser compatible and applicable to all pages. It should just be a copy/paste operation to make it work. Here's the new code:
<script type="type/javascript">
var TDs = document.getElementsByTagName("TD");
var i=0;
var tagContent = "";
while (i < TDs.length)
{
try
{
tagContent = TDs[i].innerText || TDs[i].textContent;
if (tagContent.indexOf("Workspace") == 0 || tagContent.indexOf("Workspace") == 3)
{
TDs[i+1].parentNode.removeChild(TDs[i+1]);
TDs[i].parentNode.removeChild(TDs[i]);
}
}
catch(err){}
i=i+1;
}
</script>
Hi,
Thanks for the great tip on changing newitem.aspx in the browser!
What number do I use if I want to hide "Recurrence" ?
I'm not sure what to replace the number "3" with
Hi Arif,
To make this work with the "Recurrence" field, all you have to do is change indexOf("Workspace") with indexOf("Recurrence"). This should remove the Recurrence option from the form.
If you want to remove multiple fields from the form, just add another if statement and put in the string that appears on the left when you view the form.
If this doesn't work, let me know and I'll see what I can do further.
-Ben
Thanks, it worked!
I had to change "type/javascript"
to text/javascript as well
Dude, that is awesome! I am impressed. Thank you very much for this tip.
awesome! ... I did away with the content editor web part by adding the code in designer - the trick I used was to piggyback on _spBodyOnLoadFunctionNames to get my script running at the right time. This way I could save the list as a template and reuse it w/o web part dependency.
Alex,
Great idea, thanks for the feedback!
One of the things I try to keep in mind as I put these together is to keep them as browser-based as possible so that even people without access to SP Designer can still use them. Incorporating this code into the page itself rather than a CEWP is a much more permanent & reliable solution though as there is no worry about accidentally removing the CEWP or mistyping code.
-Ben
I was so excited to find this, but can't get it to work. I'm using MOSS 2007, trying to hide specifically on an extended content type created from Event.
I added a CEWP below the event, and added some response.write lines to help test. My javascript does not appear to run at all. Is the solution posted for WSS or MOSS or both? Any suggestions?
Since this is client-side javascript, it should work regardless of which version of SharePoint you use. For this code to work, it just needs to see Workspace in the left-hand column of the form.
You mention that your javascript doesn't run at all on the page which leads me to believe that there is a typo somewhere in the code. When this happens to me I've found that putting in an alert('hi'); at the top of the code and testing it in a browser, gradually moving it down the code until it stops alerting is a good way to find the location of the typo.
If this doesn't solve your problem, please feel free to send me screenshots and source code and I'll do what I can to help troubleshoot.
mr.ben.bradley[at]gmail.com
I can only get this work on NewForm.aspx but not on ViewForm.aspx and EditForm.aspx.
I tried a JS alert but no match.
Any more ideas?
forget my comment already.... found the typo!
Hi Christoph,
I'm glad to hear that it's working! =)
-Ben
awesme,
i was searching for such thing for a long period
it did not not work with me in begining but change the script type to "text/jscript" made it succeed !
Thanks ben
Hi Fahmy,
I'm glad that it's working for you! It's strange that changing to "text/jscript" made it work for you, I would never have thought of trying that!
I did a bit of digging on Wikipedia and found that "jscript" is specific to Internet Explorer, but this is the first account I've heard of it actually preventing the code from running.
I'll keep looking to see if there's a way to write this so that it's more applicable across multiple browsers.
Thanks!
lambrite,
This may be a solution for you as well.
-Ben
Hi Ben
i was mistaken in that.
i tried to write down again the code without coping it from your page,it works fine with me in either :
using Type = "text/javascript" for all browsers (IE,Firefox...etc)
also Type= "text/jscript" but only for IE
Thanks again for that trick !!!
Here's an interesting one... When I add the CEWP to the EditForm.aspx page, it looks to work fine. When I click the "Edit Task" link on the actual item, it gives me the page, but in edit mode with a "Save and Stop Editing" button. I can click that button all day long and that toolbar remains. Oh, and the Meeting Workspace Field is still present on that page, too. The only thing that I can see is that when I click the "Edit Item" link, it uses Javascript to load up the EditForm.aspx page with the "?ID=3" tag appended to the URL with the source address. Has anyone else run into this?
Andrew,
Hrrm, that is interesting. Can you post/send screenshots? I'm not able to replicate it locally.
ben[at]bradleyit.com
-Ben
Ben - thanks so much for this (and for the HP Printer display script to boot - have had much fun with that one at my workplace ;).
Just a quick note....
On my WSSv3 installation, there is no ViewForm.aspx - rather, my installation uses DispForm.aspx.
Cheers!
-B-
Hi Blake,
Thanks for the tip! I looked back through my work and found that ViewForm.aspx in the post of the body was, in fact, a typo. It should have read DispForm.aspx as you pointed out.
Thanks for helping & I'm glad that my code is being put to work =)
-Ben
My pleasure! Keep up the good work.
I think I'll be modifying hpsetdisp.pl to cycle through a list of HP printers soon...hehehe
Many thanks to all for the code - I have the same problem as Andrew - the EditForm.aspx gives me the page, but in edit mode with a "Save and Stop Editing" button. Has anyone managed to find a solution to this problem?
Cheers
A.R.Watt
Hi A.R.,
Unfortunately, I never received screenshots showing what was happening and I wasn't able to replicate the problem locally. If you can send me screenshots of what you're trying & seeing, I'll better be able to troubleshoot it.
You can send them to me at ben[at]bradleyit.com
-Ben
Thanks for the reply Ben,
a bit of further works shows that it seems to happen when I insert a CEWP on any EditForm page - looks like it isn't the code!
Andy
Incredibly useful, thanks!
Hi Ben -
Thanks so much for this, it's exactly what I needed.
Thanks
Technomummy.
Thank you so much!!!! Exactly what i needed.
If you want to hide those labels, border and top menu in EditForm.aspx, use CSS.
Here is what you need to insert in Content Editor Web Part:
< style type="text/css" >
.ms-formfieldvaluecontainer { border:none; };
.ms-formfieldlabelcontainer, .ms-consolemptablerow { display:none; };
< /style >
use < instead of <
use > instead of >
I tried it in IE, it works great, but in FireFox it doesn't, don't know why.
ignore these 2 lines:)
use < instead of <
use > instead of >
Worked like a charm! Thank you so much for providing this for us.
Hi
I have done the same steps but still it did not worked for me
This also helped me hide a calculated column from the dispform and editform pages of a list in SharePoint Foundation 2010. Great script!
Use Sharepoint Manager instead!
You can also set the Workspace field to hidden on the columns. Either for specific calendars or globally in the site collection. There's more information at
http://blog.salamandersoft.co.uk/index.php/2011/03/removing-the-use-a-meeting-workspace-option-from-all-existing-and-new-sharepoint-calendars-in-a-site-collection/
http://blog.salamandersoft.co.uk/index.php/2011/03/using-powershell-to-remove-the-use-a-meeting-workspace-option-from-sharepoint-calendars/
Post a Comment