3

I need to get all checked out files from a document library. I am trying by following query.

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = @
"<View>
       <Query>
              <Where>
                <IsNotNull>
                    <FieldRef Name='CheckoutUser' />
                </IsNotNull>
              </Where>
         </Query>
 </View>";

Above query returns the documents those are checked out by current user. I need to get all checked out documents (checked out by any use).

update

I have required columns. When users drag and drop files without filling out those columns it's remain invisible to others. Whenever users upload document, it goes to the Manage files which have no checked in version. I need to get those files grammatically.enter image description here

2

Replace

<Where>
   <IsNotNull>
       <FieldRef Name='CheckoutUser' />                                            
   </IsNotNull>
</Where>

with

<Where>
    <Geq>
      <FieldRef Name="CheckoutUser" LookupId="TRUE" />
              <Value Type="int">0</Value>
    </Geq>
</Where>
  • The CAML Query is definitely working. You can check using U2U CAML Query builder on your site. – Ransher Singh Aug 11 '15 at 15:57
  • Ya I did that already... Not working in U2U as well as CSOM. Did you test it? – Atish Dipongkor - MVP Aug 11 '15 at 16:00
  • I responded to your comment just after testing it. Infact, I will take back my original answer as <IsNotNull> works as well. – Ransher Singh Aug 11 '15 at 16:00
  • I my library I have three documents. Two of them are checked out by another user and last one is by current user. This code shows only one document when I run as current user and shows two document when I run as other user. Actually I need three document whoever the user is. Is it the scenario for you? – Atish Dipongkor - MVP Aug 11 '15 at 16:11
  • 1
    I have required columns. When users drag and drop files without filling out those columns it's remain invisible to others. This is issue in my case. Your answer is 100% right without required columns. Any idea about required columns – Atish Dipongkor - MVP Aug 12 '15 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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