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
<div>
<p>
<b>Create Folder</b>
<br />
<input type="text" value="List Name Here" id=" DeleteFolder " />
<button id="btnclick"> Delete Folder </button>
</p>
</div>
----------------------
JS script in app.js (Paste the below methods in app.js file) Refer here
-----------------------
function FolderCreation()
{
var executor;
var getfoldername= document.getElementById("DeleteFolder").value;
// Initialize the RequestExecutor with the app web URL.
executor = new SP.RequestExecutor(appweburl);
executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('lib/Folder B')?@target='" + hostweburl + "'",
method: "POST",
}
headers:
{
"X-HTTP-Method":"DELETE"
},
success: FoldersSuccessHandler,
error: FoldersErrorHandler
});
}
//Populate the selectFolders control after retrieving all of the folders.
function FoldersSuccessHandler(data) {
alert("Folder Deleted successfully in Library");
}
function FoldersErrorHandler(data, errorCode, errorMessage) {
alert("Could not Delete a Folder in Library: " + errorMessage);
}
//Utilities
// Retrieve a query string value.
// For production purposes you may want to use a library to handle the query string.
function getQueryStringParameter(paramToRetrieve) {
var params = document.URL.split("?")[1].split("&");
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramToRetrieve) return singleParam[1];
}
}
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
<div>
<p>
<b>Create Folder</b>
<br />
<input type="text" value="List Name Here" id=" DeleteFolder " />
<button id="btnclick"> Delete Folder </button>
</p>
</div>
----------------------
JS script in app.js (Paste the below methods in app.js file) Refer here
-----------------------
function FolderCreation()
{
var executor;
var getfoldername= document.getElementById("DeleteFolder").value;
// Initialize the RequestExecutor with the app web URL.
executor = new SP.RequestExecutor(appweburl);
executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('lib/Folder B')?@target='" + hostweburl + "'",
method: "POST",
}
headers:
{
"X-HTTP-Method":"DELETE"
},
success: FoldersSuccessHandler,
error: FoldersErrorHandler
});
}
//Populate the selectFolders control after retrieving all of the folders.
function FoldersSuccessHandler(data) {
alert("Folder Deleted successfully in Library");
}
function FoldersErrorHandler(data, errorCode, errorMessage) {
alert("Could not Delete a Folder in Library: " + errorMessage);
}
//Utilities
// Retrieve a query string value.
// For production purposes you may want to use a library to handle the query string.
function getQueryStringParameter(paramToRetrieve) {
var params = document.URL.split("?")[1].split("&");
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramToRetrieve) return singleParam[1];
}
}
No comments:
Post a Comment