Saturday, August 22, 2009

Restricting adding new item for contibutors

So many time I have been asked for a way where Contributors are allowed to reply or edit the existing item but should not be able to add any new entry.

User should be able reply to the discussion but not able to create a new one.

This is a no code workaround as users can still find a way to bring the New form back. Using DataView webpart we will hide the form for all the users except Administrators.

You should enable Content Approval to be able to control it fully.


1. Create a new file with the name 'Information.webpart'

2. Paste the WebPart definition into the file and save it.

3. Now navigate to Site Action > Site Settings > WebPart Gallery

4. Upload the new webpart file here. ( There is a reason why you will need to do it this way, as you will not able to import this webpart using import option )

5. Now go to the list you want with restricted new item.

6. Click on new item and enter into Edit mode
( I know Edit page is missing but you need paste following command javascript:MSOLayout_ToggleLayoutMode(); into your browser address bar and hit enter to get the edit mode )Check Srini's post on how to toggle

7. Add the new webpart from the WebPart picker popup as 2nd Webpart on the page. Make sure new webpart is the 2nd webpart.Otherwise it will not work.

8. Exit Edit mode and now test it using visitor account.

WebPart Definition File:

<webPart xmlns="">
<type name="Microsoft.SharePoint.WebPartPages.DataFormWebPart, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
<property name="FireInitialRow" type="bool">True</property>
<property name="TitleIconImageUrl" type="string" />
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="CacheXslStorage" type="bool">True</property>
<property name="ViewContentTypeId" type="string" />
<property name="Description" type="string" />
<property name="DataSourcesString" type="string" />
<property name="AllowZoneChange" type="bool">True</property>
<property name="ParameterBindings" type="string" null="true" />
<property name="PageSize" type="int">-1</property>
<property name="TitleUrl" type="string" />
<property name="ViewFlag" type="string" />
<property name="Xsl" type="string">

<xsl:stylesheet version="1.0" exclude-result-prefixes="rs z o s ddwrt dt msxsl" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xsl="" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="" xmlns:asp="" xmlns:ddwrt="" xmlns:o="urn:schemas-microsoft-com:office" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:ddwrt2="urn:frontpage:internal"><xsl:output method="html" indent="no" /><xsl:decimal-format NaN="" />

<xsl:template match="/" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="" xmlns:asp="">

<xsl:if test="not(ddwrt:IfHasRights(9223372036854775807))">

<script type="text/javascript" >
var div2 = document.getElementById('WebPartWPQ2'); = 'none';

You dont have permissions to create a new announcement.



<property name="NoDefaultStyle" type="string" null="true" />
<property name="Direction" type="direction">NotSet</property>
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="ListName" type="string" null="true" />
<property name="Hidden" type="bool">False</property>
<property name="DisplayName" type="string" />
<property name="SampleData" type="string" null="true" />
<property name="HelpUrl" type="string" />
<property name="ChromeType" type="chrometype">Default</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="Height" type="string" />
<property name="DataFields" type="string" />
<property name="Default" type="string" />
<property name="ChromeState" type="chromestate">Normal</property>
<property name="DataSourceID" type="string" />
<property name="AllowClose" type="bool">True</property>
<property name="CacheXslTimeOut" type="int">86400</property>
<property name="AllowMinimize" type="bool">True</property>
<property name="AllowEdit" type="bool">True</property>
<property name="XslLink" type="string" null="true" />
<property name="Title" type="string">Information</property>
<property name="Width" type="string" />
<property name="ShowWithSampleData" type="bool">False</property>
<property name="ExportMode" type="exportmode">All</property>
<property name="AllowHide" type="bool">True</property>
<property name="AllowConnect" type="bool">True</property>
1. You can edit the webpart to change the message user gets when he don't have access.

Permission Values