0

I have the following table with columns:

Editor | _UIVersionString | Title | LookupNumber | Author 
  a    |    b             | Title1|   100;800    | admin

I use the following query caml

<Or>
<Or>
<Contains>
<FieldRef Name="Editor"/>
<Value Type="Text">a</Value>
</Contains>

<Contains>
<FieldRef Name="_UIVersionString"/>
<Value Type="Text">a</Value>
</Contains>

</Or>

<Or>
<Or>
<Contains>
<FieldRef Name="Title"/>
<Value Type="Text">a</Value>
</Contains>
<Contains>
<FieldRef Name="Lookup" />
<Value Type="Lookup">a</Value>
</Contains>
</Or>

<Or>
<Contains>
<FieldRef Name="LookupNumber" />
<Value Type="Text">a</Value>
</Contains>
<Contains><FieldRef Name="Author"/>
<Value Type="Text">a</Value>
</Contains>
</Or>

</Or>
</Or>

But this always throws an error! Why???????

2 Answers 2

0

Firstly the Query is not properly created. Editor and Author are User type fields i.e Value Type='User'. Similarly, the LookupNumber in your case seems to support multiple values, hence the type should be Value Type='LookupMulti'. This is how your query should look like:

<Query>
   <Where>
      <Or>
         <Contains>
            <FieldRef Name='Editor' />
            <Value Type='User'>a</Value>
         </Contains>
         <Or>
            <Contains>
               <FieldRef Name='_UIVersionString' />
               <Value Type='Text'>a</Value>
            </Contains>
            <Or>
               <Contains>
                  <FieldRef Name='Title' />
                  <Value Type='Text'>a</Value>
               </Contains>
               <Or>
                  <Contains>
                     <FieldRef Name='LookupNumber' />
                     <Value Type='LookupMulti'>100</Value>
                  </Contains>
                  <Contains>
                     <FieldRef Name='Author' />
                     <Value Type='User'>a</Value>
                  </Contains>
               </Or>
            </Or>
         </Or>
      </Or>
   </Where>
</Query>

Finally, you should create your quires using CAML QUery Builder. It makes working with CAML quries very easy.

1
  • That was helpful, but in the end I decided to do a validation on any numeric input so that any non-numeric input would not be accepted. Commented Feb 3, 2015 at 3:02
0

You have mentioned <FieldRef Name="Lookup" />. It should be <FieldRef Name="LookupNumber" /> looking at your columns.

Not sure whats your exact requirement but you may want to use LookupId="TRUE" and test again.

Ref: http://blogs.msdn.com/b/voyage/archive/2014/06/09/caml-queries-to-remember.aspx https://abstractspaces.wordpress.com/2008/05/05/caml-query-lookup-field-by-id-not-by-value/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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