Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function consultBP() {
- try
- {
- var customlist ;
- var clientContext = new SP.ClientContext.get_current();
- var oWebsite = clientContext.get_web();
- var oList = oWebsite.get_lists().getByTitle( 'WO_Projects' );
- var camlQuery = new SP.CamlQuery();
- camlQuery.set_viewXml( '<View><Query><Where><Geq><FieldRef Name='ID'/>' +
- '<Value Type='Number'>1</Value></Geq></Where></Query></View>' );
- this.customlist = oList.getItems( camlQuery );
- clientContext.load( this.customlist );
- clientContext.executeQueryAsync(
- Function.createDelegate( this, onQuerySucceededClarityID ),
- Function.createDelegate( this, onQueryFailedClarityID ));
- }catch(err){
- erroSearchBP++;
- if( erroSearchBP < 100 ) setTimeout( function() { consultBP(); } ,200 );
- else alert( erroCarregarPagina );
- }
- }
- function onQuerySucceededClarityID(){
- //........
- }
- function onQueryFailedClarityID( sender, args ) {
- alert( "Failed" );
- }
- function getSubWebProjStatus() {
- $.each(subWebsArray, function() {
- var subSiteUrl = this.Url;
- var targetUrl = this.Url + "/_vti_bin/lists.asmx";
- var listName = "Project Tasks";
- var soapEnv = "<?xml version="1.0" encoding="utf-8"?>" +
- "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">" +
- " <soap:Body> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>" + listName +
- "</listName> <viewName></viewName> <query></query> <viewFields></viewFields>" +
- " <rowLimit>2000</rowLimit> <queryOptions><QueryOptions xmlns="">" +
- "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
- "<ViewAttributes Scope="RecursiveAll"/>" +
- "</QueryOptions></queryOptions>" +
- " </GetListItems> </soap:Body> </soap:Envelope>";
- $.ajax({
- cache: false,
- url: targetUrl,
- type: "POST",
- dataType: "xml",
- data: soapEnv,
- contentType: "text/xml; charset=utf-8",
- beforeSend: function(xhr) {
- xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems");
- },
- complete: function(msg) {
- var siteStatus = "N/A";
- var percentComplete = 0;
- if (msg.status === 200) {
- var totalTaskCount = $(msg.responseXML).find("z\:row, row").length;
- var completedTaskCount = 0;
- if (totalTaskCount > 0) {
- $(msg.responseXML).find("z\:row, row").each(function() {
- if ($(this).attr("ows_Status") !== undefined && $(this).attr("ows_Status").length > 0) {
- var taskStatus = $(this).attr("ows_Status").split("#")[1];
- if (taskStatus === "Completed") {
- completedTaskCount++;
- }
- }
- });
- percentComplete = Math.round(completedTaskCount / totalTaskCount * 100);
- siteStatus = completedTaskCount + " of " + totalTaskCount + " (" + percentComplete + "%) Tasks Completed";
- }
- displayProjStatus(subSiteUrl, siteStatus, percentComplete);
- } else {
- //Failure
- var errorCode = $(msg.responseXML).find("errorcode").text();
- var errorString = $(msg.responseXML).find("errorstring").text();
- if (errorString.length === 0) {
- errorString = $(msg.responseXML).find("faultstring").text();
- }
- errorString = errorString.replace(/(rn|n|r)/gm, "");
- showStatusBar("Oh no! " + errorString + "(" + errorCode + ")");
- }
- },
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement