1
votes

I use the join query in sharepoint. but it's seem i get an error on the when i get value from the Lookup lists.

Here is my design

  • Document as a Document Library type have a Id

    Id | DocLeafRef
    ---+-------------
    1  | Document A
    2  | Document B
    
  • Activities list, have a foreign key 'e8_document' that reference to the Document Id

    Id | e8_document | Name
    ---+-------------+-----------
    1  | 1           | Activity A
    2  | 1           | Activity B
    3  | 1           | Activity C
    4  | 2           | Activity D
    

Here is the result that I need to get.

Id | e8_document | Name       | DocLeafRef
---+-------------+--------------------------
1  | 1           | Activity A | Document A
2  | 1           | Activity B | Document A
3  | 1           | Activity C | Document A
4  | 2           | Activity D | Document B

Could any one please help me what's wrong in my query. Here is my query

<View>
  <ViewFields>
    <FieldRef Name = 'DocLeafRef'/>
    <FieldRef Name = 'ID'/>
    <FieldRef Name = 'e8_document'/>
    <FieldRef Name = 'Title'/>
    <FieldRef Name = 'Author'/>
    <FieldRef Name = 'Created'/>
  </ViewFields>
  <Joins>
    <Join Type = 'INNER' ListAlias = 'Documents'>
      <Eq>
         <FieldRef Name ='e8_document' RefType = 'Id'/>
         <FieldRef Name ='ID' List ='Documents'/>
      </Eq>
    </Join>
  </Joins>
  <ProjectedFields>
    <Field ShowField ='FileLeafRef' Type ='Lookup' Name ='DocLeafRef' List ='Documents'/>
  </ProjectedFields>
  <Query>
     <Where>
        <Eq>
           <FieldRef Name='e8_caseId'></FieldRef>
           <Value Type = 'Number'>23</Value>
        </Eq>
     </Where>
  </Query>
</View>

And here is the exception Value does not fall within the expected range

1

1 Answers

1
votes

Likely the problem is that FileLeafRef is not one of the field types that can be used in a projected field.

Refer to the documentation here.

Only the following types of fields can be included in a ProjectedFields element:

•Calculated (treated as plain text)

•ContentTypeId

•Counter

•Currency

•DateTime

•Guid

•Integer

•Note (one-line only)

•Number

•Text