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've three lists: Competitions, Works and WorksVotes, linked to each other through Lookup fields. WorksVotes list has Lookup field to Works list, and Works list has Lookup field to Competitions list. What I need is to display the Competition in the WorksVotes list. I wrote some CAML code with 2 Joins which works fine with SPQuery object:

var query = new SPQuery();
                    query.Query = "<OrderBy><FieldRef Name=\"ID\" /></OrderBy>";

                    query.ViewFields = "<FieldRef Name=\"Title\" /><FieldRef Name=\"Attachments\" /><FieldRedf Name=\"LinkTitle\" /><FieldRef Name=\"CompetitionTitle\" />";

                    query.Joins =
                        @"<Join Type=""INNER"" ListAlias=""worksList"">
                              <FieldRef Name=""CompetitionWork"" RefType=""ID"" />
                              <FieldRef Name=""ID"" List=""worksList"" />
                          <Join Type=""INNER"" ListAlias=""competitionsList"">
                              <FieldRef List=""worksList"" Name=""Competition"" RefType=""ID"" />
                              <FieldRef List=""competitionsList"" Name=""ID"" />
                    query.ProjectedFields = "<Field Name=\"CompetitionTitle\" Type=\"Lookup\" List=\"competitionsList\" ShowField=\"Title\" />";

After testing I added this CAML into schema.xml file that defines the WorksVotes list:

   <FieldRef Name="Title"></FieldRef>
   <FieldRef Name="CompetitionTitle"></FieldRef>
          <Join Type="INNER" ListAlias="worksList">
              <FieldRef Name="CompetitionWork" RefType="ID" />
              <FieldRef Name="ID" List="worksList" />
          <Join Type="INNER" ListAlias="competitionsList">
              <FieldRef List="worksList" Name="Competition" RefType="ID" />
              <FieldRef List="competitionsList" Name="ID" />
          <Field Name="CompetitionTitle" Type="Lookup" List="competitionsList" ShowField="Title" />

But in this case I get an SPException telling that the "CompetitionTitle" field is unavailable or does not exist. What I'm doing wrong?

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.