In a Documents library, many documents are attached of type word, excel and pdf , i want to find out only PDF Documents using SharePoint server side API? After finding pdf type documents i want to check if they are checked out or not? What will be the possible code to accomplish this?


1 Answer 1


Not sure if you're using 2010 or 2013, but here are a couple of CAML queries you should be able to use for either: 1.) How to write a caml query that filters by .pdf or folders? 2.) https://rmanimaran.wordpress.com/2010/10/19/getfind-all-checked-out-documents-from-a-document-library-using-caml/

Here is some SharePoint 2013 app sample code which gets all pdf files which have been checked out (you can modify the CAML query to also just get all pdf files, checked out or not):

            CamlQuery camlQuery = new CamlQuery();
        camlQuery.ViewXml = @"
                <View Scope='RecursiveAll'>
                                    <FieldRef Name='File_x0020_Type'/>
                                    <Value Type='Text'>pdf</Value>
                                    <FieldRef Name='CheckoutUser' LookupId='TRUE'/>
                                    <FieldRef Name='CheckoutUser' LookupId='TRUE'/>
                                    <Value Type='User'>2</Value>


        context.Load(docList.RootFolder, r => r.ServerRelativeUrl);
        camlQuery.FolderServerRelativeUrl = docList.RootFolder.ServerRelativeUrl + "/";

        ListItemCollection collListItem = docList.GetItems(camlQuery);
            lc => lc.Include(
                i => i.DisplayName,
                i => i.Id));


        foreach (var item in collListItem)
            MessageBox.Show(String.Format("{0} is checked out!", item.DisplayName));

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.