Created
June 1, 2018 06:05
-
-
Save hammadbinarif/7559f4352d38833e335e9073a20061a3 to your computer and use it in GitHub Desktop.
This file contains 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
var script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script); | |
function retrieveData(url) { | |
var dfd = jQuery.Deferred(); | |
console.log('Data url is + ' + url) | |
jQuery.ajax({url:url, | |
type: "GET", | |
dataType: "json", | |
headers: {Accept: "application/json;odata=verbose" } | |
, success: function (data, textStatus, XmlHttpRequest) { | |
if (null != data.d.__next) { | |
retrieveData(data.d.__next).done(function (results) { | |
dfd.resolve(results.concat(data.d.results)); | |
}); | |
} | |
else { | |
dfd.resolve( data.d.results ); | |
} | |
}, | |
error: function (XmlHttpRequest, textStatus, errorThrown) { alert('Unable to retrieve data:' + textStatus); } | |
}); | |
return dfd.promise(); | |
} | |
function DeleteSites() { | |
var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/ProjectData/[en-US]/Projects()?" | |
+ "$filter=ProjectWorkspaceInternalUrl%20ne%20null" | |
+ "&$select=ProjectId,ProjectName,ProjectWorkspaceInternalUrl" | |
+ "&$orderby=ProjectName"; | |
retrieveData(url).done (function (projects) { | |
console.log ("Retreived projects count " + projects.length); | |
for (var i = 0; i < projects.length; i++) { | |
var projectId = projects[i].ProjectId; | |
var projectName = projects[i].ProjectName; | |
console.log ("Deleting Project Site for Project: " + projectName); | |
$get('idOperation').value = "DeleteWeb"; | |
$get('idProjectUID').value = projectId; | |
$get('idProjectName').value = projectName; | |
DoCallback(); | |
} | |
}); | |
}; | |
function PJ_ServerCallback_Complete(retString, context) | |
{ | |
var oReturnData = new PJServerCallBackReturnData(retString); | |
console.log("Return Message = " + oReturnData.Message); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment