Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 AuthorizationFilter nor IsIncludedFilter, the webpart is displaying as I expect, but for all users
  • include AuthorizationFilter but not IsIncludedFilter, the webpart is displaying as I expect, but still for all users.
  • include both AuthorizationFilter and IsIncludedFilter. 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 ?

share|improve this question
    
Did you ever find a solution to this? –  tarjeieo Sep 3 '12 at 12:30
    
Unfortunately, no. I set up the audiences from a feature receiver. –  Steve B Sep 4 '12 at 8:39
    
Yup, that's what I ended up with as well –  tarjeieo Sep 10 '12 at 8:35

1 Answer 1

i know it is a bit late but i was just involved in a similar Scenario: I used the MembersWebPart in SharePoint 2013 and this is a working example:

<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
    <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
    <TypeName>Microsoft.SharePoint.WebPartPages.MembersWebPart</TypeName>
    <Title>$Resources:core,MembersWebPartTitle;</Title>
    <Description>$Resources:core,MembersWebPartDescription;</Description>
    <PartImageLarge>/_layouts/15/images/msmeml.gif</PartImageLarge>
    <AuthorizationFilter>;;;;Besitzer</AuthorizationFilter>
    <IsIncludedFilter>;;;;Besitzer</IsIncludedFilter>
</WebPart>

Ronny

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.