1

I want to get all files under document library which is checked out.

I tried this rest query in SharePoint hosted app

window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl + "/_api/web/lists(guid'" + listid + "')/Files?$select=*,FileRef&$expand=File,CheckedOutByUser/Id,ListItemAllFields/ContentType,ListItemAllFields/File&$filter=CheckedOutByUser/Id eq " + _spPageContextInfo.userId;

I can get all root location checked out files by current user but how to get all checked out files under all folders also.

Thanks

2

Grabbing info from: Sharepoint REST api - Recursively fetch all folders in a document library -

function getListItems(webUrl,listTitle, viewXml) 
{
    var url = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getitems"; 
    var queryPayload = {  
               'query' : {
                      '__metadata': { 'type': 'SP.CamlQuery' }, 
                      'ViewXml' : viewXml
               }
    };

    return $.ajax({
           url: url,
           method: "POST",
           contentType: "application/json;odata=verbose",
           data: JSON.stringify(queryPayload),
           headers: {
              "X-RequestDigest": $("#__REQUESTDIGEST").val(),
              "Accept": "application/json; odata=verbose"
           }
     });
}

function getAllFolderItems(webUrl,listTitle)
{
    var viewXml = '<View Scope="RecursiveAll"><Query><Where><Eq><FieldRef Name="FSObjType" /><Value Type="Integer">1</Value></Eq></Where></Query></View>';
    return getListItems(webUrl,listTitle,viewXml);
}

where the query is:

<View Scope="RecursiveAll">
     <Query>
         <Where>
           <Geq>
              <FieldRef Name="CheckoutUser" LookupId="TRUE" />
              <Value Type="int">0</Value>
           </Geq>
         </Where>
     </Query>
</View>

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.