Sharepoint - Get Check-out Documents using Javascript
I can suggest 3 ways to achieve this:
First 2 are REST and Javascript:
You could use SP.File.checkOutType property to determine whether document is checked out of a document library
REST
$.ajax({url: "/_api/web/getFileByServerRelativeUrl('" + docUrl + "')/checkOutType",
headers: { "Accept": "application/json; odata=verbose" },
success: function(data) {
if(data.d.CheckOutType == 0) {
console.log('The file is checked out');
}
}
});
CSOM (JavaScript)
var context = SP.ClientContext.get_current();
var web = context.get_web();
var file = web.getFileByServerRelativeUrl(docUrl);
context.load(file);
context.executeQueryAsync(
function(){
if(file.get_checkOutType() == SP.CheckOutType.online) {
console.log('The file is checked out');
}
},
function(sender, args){
console.log(args.get_message());
}
);
Third one is the easiest based on Spservices:
SpServices
Use SpServices GetListItems
and write a query where you search for all the items where "CheckOutType
"("checkedOutTo
" please check the internal name) is not null. You can then iterate through all the items.
Do let me know if you need help writing the query. Cheers!