Question

I'm trying to join my list and the users joining by the author (in a related element listview - XsltListViewWebPart):

    <Query>
        <Where>
            <Eq>
                <FieldRef Name="MitarbeiterOffice"/>
                <Value Type="Text">MyOffice</Value>
            </Eq>
        </Where>
        <OrderBy>
            <FieldRef Name="Created" Ascending="FALSE"/>
        </OrderBy>
    </Query>
    <ViewFields>
        <FieldRef Name="Author"/>
        <FieldRef Name="Title"/>
    </ViewFields>
    <Joins>
        <Join Type="LEFT" ListAlias="Users">
            <Eq>
                <FieldRef Name="Author" RefType="ID"/>
                <FieldRef List="Users" Name="ID"/>
            </Eq>
        </Join>
    </Joins>
    <ProjectedFields>
        <Field Name="MitarbeiterOffice" Type="Lookup" List="Users" ShowField="Office"/>
    </ProjectedFields>

I get whit screen with correlation ID, error says:

Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.    

Why? It's not the first time I'm joining lists in sharepoint but it's the first time on the Author.

Était-ce utile?

La solution

I found out that the problem is not the CAML Query but the UserContextFilterWebPart i connected to and IF there is a JSLink defined.

My complete caml:

    <View //all the view attributes >
        <Query>
            <Where>
                <Eq>
                    <FieldRef Name="Buro"/>
                    <Value Type="Text">{Office}</Value>
                </Eq>
            </Where>
            <OrderBy>
                <FieldRef Name="Created" Ascending="FALSE"/>
            </OrderBy>
        </Query>
        <ViewFields>
            <FieldRef Name="Created"/>
            <FieldRef Name="Author"/>
            <FieldRef Name="LinkTitle"/>
            <FieldRef Name="Status"/>
            <FieldRef Name="Priority"/>
            <FieldRef Name="Buero"/>
            <FieldRef Name="Position"/>
            <FieldRef Name="Body"/>
        </ViewFields>
        <Joins>
            <Join Type="LEFT" ListAlias="Users">
                <Eq>
                    <FieldRef Name="Author" RefType="ID"/>
                    <FieldRef List="Users" Name="ID"/>
                </Eq>
            </Join>
        </Joins>
        <ProjectedFields>
            <Field Name="Buro" Type="Lookup" List="Users" ShowField="Office"/>
        </ProjectedFields>
        <RowLimit Paged="TRUE">100</RowLimit>
        <RowLimit Paged="TRUE">999</RowLimit>
        <JSLink>clienttemplates.js</JSLink>
        <XslLink Default="TRUE">main.xsl</XslLink>
        <Toolbar Type="Standard"/>
    </View>

In the parameterbindings of the webpart i added <ParameterBinding Name="Office" Location="None" DefaultValue="" /> in order to be able to filter the list using a UserContextFilterWebPart. In this scenario i get a correlation. By simply removing the the clienttemplates.js leaving the empty tag <JSLink/> it works, but the resulting view is really ugly: enter image description here

The other way, keeping the JSLink and removing the userfilter the view would be: enter image description here

I'm going to open a new question regarding this issue...

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top