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

1 Answer 1

2

Replace

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

with

<Where>
    <Geq>
      <FieldRef Name="CheckoutUser" LookupId="TRUE" />
              <Value Type="int">0</Value>
    </Geq>
</Where>
14
  • The CAML Query is definitely working. You can check using U2U CAML Query builder on your site. Aug 11, 2015 at 15:57
  • Ya I did that already... Not working in U2U as well as CSOM. Did you test it? Aug 11, 2015 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. Aug 11, 2015 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? Aug 11, 2015 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 Aug 12, 2015 at 6:33

Your Answer

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

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