TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get Checked-Out Status of the File in SharePoint
Shantha Kumar T
Dec 26
2015
Code
1.1
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
function getcheckoutStatus(listname, itemid)
{
var clientContext = SP.ClientContext.get_current();
if
(clientContext != undefined && clientContext !=
null
)
{
var webSite = clientContext.get_web();
this
.list = webSite.get_lists().getByTitle(listname);
this
.item = list.getItemById(itemid);
this
.file =
this
.item.get_file();
clientContext.load(
this
.file,
'CheckOutType'
,
'Name'
,
'CheckedOutByUser'
);
clientContext.executeQueryAsync(Function.createDelegate(
this
,
this
.OnLoadSuccess), Function.createDelegate(
this
,
this
.OnLoadFailed));
}
}
function OnLoadSuccess(sender, args)
{
if
(
this
.file.get_checkOutType() < 2) console.log(
this
.file.get_name() +
" is checked out by "
+
this
.file.get_checkedOutByUser().get_title());
else
console.log(
this
.file.get_name() +
" is not checked out."
);
}
function OnLoadFailed(sender, args)
{
try
{
console.log(
'Error: '
+ args.get_message() +
'\n'
+ args.get_stackTrace());
}
catch
(err)
{}
}
function injectMethod()
{
getcheckoutStatus(
"Site Assets"
, 4);
}
ExecuteOrDelayUntilScriptLoaded(injectMethod,
"sp.js"
);
Checked-out status
SharPoint
ecmsScript