Hope you have idea how to create SharePoint App.
If you are using NAPA tool then replace below codes in APP.js file.
So i am just focusing on the REST script part to do the activities
I recommend to go through REST API for SP document libraries before proceed.
HTML file in Default.aspx
----------------------
JS script in app.js (Paste the below methods in app.js file) Refer here
-----------------------
function filecheckin()
{
var executor;
// Initialize the RequestExecutor with the app web URL.
executor = new SP.RequestExecutor(appweburl);
executor = new SP.RequestExecutor(appweburl);
executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/getfilebyserverrelativeurl('/sites/apps/Shared Documents/filename1.txt')/checkin(comment='Check-in comment.',checkintype=0)?@target='" + hostweburl + "'",
method: "POST",
headers:
{
"accept": "application/json; odata=verbose"
},
success: function(data)
{
alert("success:File Checked IN");
},
error: function(err)
{
alert("error: " + JSON.stringify(err));
}
});
}
If you are using NAPA tool then replace below codes in APP.js file.
So i am just focusing on the REST script part to do the activities
I recommend to go through REST API for SP document libraries before proceed.
HTML file in Default.aspx
----------------------
JS script in app.js (Paste the below methods in app.js file) Refer here
-----------------------
function filecheckin()
{
var executor;
// Initialize the RequestExecutor with the app web URL.
executor = new SP.RequestExecutor(appweburl);
executor = new SP.RequestExecutor(appweburl);
executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/getfilebyserverrelativeurl('/sites/apps/Shared Documents/filename1.txt')/checkin(comment='Check-in comment.',checkintype=0)?@target='" + hostweburl + "'",
method: "POST",
headers:
{
"accept": "application/json; odata=verbose"
},
success: function(data)
{
alert("success:File Checked IN");
},
error: function(err)
{
alert("error: " + JSON.stringify(err));
}
});
}
No comments:
Post a Comment