We can able to create the SharePoint List/Library Folders using REST web services.
<script type="text/javascript">
function CreateFolder (){
var url_web;
var pictureLibrary
var folder_name;
var folder_path;
var mainfolder = ["Baikalit-SKC", "MC-Irkutsk", "Orion", "PM-Auto", "Sot motors", "STS-avtomobili"];
var arr = ["0_Dealer general info", "1_Sales", "2_Aftersales", "3_Network", "4_Finance", "5_Marketing", "6_Training"];
url_web = _spPageContextInfo.webAbsoluteUrl;
pictureLibrary = 'Dealer Performance Monitor';
//folder_name = 'jasonscript';
for ( var j = 0, M = mainfolder.length; j < M; j++ ) {
for ( var i = 0, l = arr.length; i < l; i++ ) {
folder_path = pictureLibrary + '/9_Siberian FD/'+mainfolder[j]+'/' + arr[i];
jQuery.ajax({
'url' : url_web + "/_api/Web/Folders/Add('"+ folder_path + "')",
'type' : 'POST',
'headers' : {
'accept' : 'application/json; odata=verbose',
'content-type' : 'application/json; odata=verbose',
'X-RequestDigest' : $('#__REQUESTDIGEST').val()
},
'success' : function (evt){
// folder has been created
},
'error' : function (jqXHR, textStatus, errorThrown){
// handle the error
alert(errorThrown);
}
});
}
}
alert("Created Folder");
}
</script>
<input type="button" Name="Submit" value="Create Sub Folder" onclick="CreateFolder();"></input>
<table border="0" cellpadding="0" width="100%" id='listPermsTable'> </table>
<script type="text/javascript">
function CreateFolder (){
var url_web;
var pictureLibrary
var folder_name;
var folder_path;
var mainfolder = ["Baikalit-SKC", "MC-Irkutsk", "Orion", "PM-Auto", "Sot motors", "STS-avtomobili"];
var arr = ["0_Dealer general info", "1_Sales", "2_Aftersales", "3_Network", "4_Finance", "5_Marketing", "6_Training"];
url_web = _spPageContextInfo.webAbsoluteUrl;
pictureLibrary = 'Dealer Performance Monitor';
//folder_name = 'jasonscript';
for ( var j = 0, M = mainfolder.length; j < M; j++ ) {
for ( var i = 0, l = arr.length; i < l; i++ ) {
folder_path = pictureLibrary + '/9_Siberian FD/'+mainfolder[j]+'/' + arr[i];
jQuery.ajax({
'url' : url_web + "/_api/Web/Folders/Add('"+ folder_path + "')",
'type' : 'POST',
'headers' : {
'accept' : 'application/json; odata=verbose',
'content-type' : 'application/json; odata=verbose',
'X-RequestDigest' : $('#__REQUESTDIGEST').val()
},
'success' : function (evt){
// folder has been created
},
'error' : function (jqXHR, textStatus, errorThrown){
// handle the error
alert(errorThrown);
}
});
}
}
alert("Created Folder");
}
</script>
<input type="button" Name="Submit" value="Create Sub Folder" onclick="CreateFolder();"></input>
<table border="0" cellpadding="0" width="100%" id='listPermsTable'> </table>
0 comments: