I have a module that deploys some page.
I'm adding webparts to these page, using a <AllUsersWebPart> node within a <View>:
<View WebPartZoneID="Body"
WebPartOrder="5"
List="Lists/mylist"
BaseViewID="4"
Name="My Title">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">My title</property>
<property name="AllowHide">False</property>
<property name="AllowMinimize">False</property>
<property name="AuthorizationFilter">;;;;MySharepointGroup</property>
<property name="IsIncludedFilter">;;;;MySharepointGroup</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
As you can see, I'm trying to set the audience of the webpart to a specific SharePoint group, but this does not works as expected.
If I:
- don't include neither
AuthorizationFilternorIsIncludedFilter, the webpart is displaying as I expect, but for all users - include
AuthorizationFilterbut notIsIncludedFilter, the webpart is displaying as I expect, but still for all users. - include both
AuthorizationFilterandIsIncludedFilter. this time, the webpart is in error, with this error :
[WebPartPageUserException: The file format is not valid. Try importing a Web Part file (.WebPart).] at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean clearConnections) at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, Uri webPartPageUri, SPWeb spWeb) at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CompressWebPartNoSave(Boolean isClosed)
In the ULS log, there is exactly the same message, with no more error or warning.
I know I could set this audience from code, but I'd like keep my full declarative model.
What is the correct way to setup audience from xml ?