-
-
Save gokhandemirhan/f6fa077bc1684cc1b95f to your computer and use it in GitHub Desktop.
SharePoint JS: SP.File.checkOutType property gets a value that indicates how the file is checked out of a document library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get file checkout type via CSOM (JavaScript) | |
var context = SP.ClientContext.get_current(); | |
var web = context.get_web(); | |
var file = web.getFileByServerRelativeUrl(pageUrl); | |
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()); | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get file checkout type via REST | |
$.ajax({url: "/_api/web/getFileByServerRelativeUrl('" + pageUrl + "')/checkOutType", | |
headers: { "Accept": "application/json; odata=verbose" }, | |
success: function(data) { | |
if(data.d.CheckOutType == 0) { | |
console.log('The file is checked out'); | |
} | |
} | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isCheckedOut() { | |
var isCheckedOut = false; | |
if (typeof(PageState) != "undefined" && PageState) | |
{ | |
isCheckedOut = PageState.ItemIsCheckedOutToCurrentUser == "1"; | |
} | |
if (!isCheckedOut) | |
{ | |
//do redirect | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment