Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Workflows on a Sub-Site

  Asked By: Norberto    Date: Feb 07    Category: Sharepoint    Views: 1246

The Content Query Web Part is an out of box rollup web part that may
do the trick.

Alternately, there's a way to open the site in SP Designer, and in
the Data Source Library, click Connect to another library, and pick
the subsite's url. That way, you could pick any list or library from
that sub-site to display a level up on the main site.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Jagjit Phutane     Answered On: Feb 07

The following code came from an excellent blog post by AARO HAYDO in
2007. Works really nicely. Basically put a CEWP on the site  you want ,
insert this Javascript code using the Source Editor. The one change you
will need to do is alter the part  in this line:



wsURL += "sub1/_vti_bin/lists.asmx";





So sub1 is a subsite I have.



The code is elegant and simple. Basically he is invoking the lists web
service. Returning a XML response packet and formatting the results set
into the CEWP.



Just shows how powerful the CEWP is!

-------------------------------------



<span id=ListList> </span>



<script language=javascript>



//Lists in area

//Uses SharePoint web  Service API to retrieve list  of lists in current
area

//Author: Aaron Haydo, ashaydo@...

//Date creaed: 6-JUL-2007



getListList();



function getListList() {



var txt = document.getElementById("ListList");



//Build SharePoint Web Service url  based on current location

var wsURL;

wsURL = window.location.protocol+"//";

wsURL += window.location.host;

var path = window.location.pathname.split("/");

path.pop();

var x;

for (x in path) {

wsURL += path[x] + "/";

}

wsURL += "sub1/_vti_bin/lists.asmx";



//SOAP Action and XML

var wsSoapAction =
"http://schemas.microsoft.com/sharepoint/soap/GetListCollection" target="_blank" rel="nofollow">schemas.microsoft.com/.../GetListCollection";

var wsXML = '<?xml version="1.0" encoding="utf-8"?>';

wsXML += '<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" target="_blank" rel="nofollow">http://www.w3.org/2001/XMLSchema-instance" ';

wsXML += 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ';

wsXML += 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';

wsXML += '<soap:Body>';

wsXML += '<GetListCollection
xmlns="http://schemas.microsoft.com/sharepoint/soap/" />';

wsXML += '</soap:Body>';

wsXML += '</soap:Envelope>';



//Create XML Document and get HTTP response using XMLHTTP object

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

var httpResponse = getServiceResults(wsURL, wsSoapAction, wsXML);



//If getServiceResults returns a 404, then it's probably because the

//page is being launched from a document library  instead of a web part

if (parseInt(httpResponse) == 404) {

txt.innerHTML = "<p>This code can only be executed from a web
part.</p>";

return;

}

else {

xmlDoc.loadXML(httpResponse);

}



//Get results into collection

listitems = xmlDoc.getElementsByTagName("List");



//Loop through results and build table rows

var output = "";

for (var x = 0; x < listitems.length; x++) {

output += "<tr title='";

output +=
listitems(x).getAttributeNode("Description").text.replace(/'/g,"`");

output += "'>";

output += "<td class='ms-vb-icon' valign='top'>";

output += "<a href='" +
listitems(x).getAttributeNode("DefaultViewUrl").text + "'>";

output += "<img src='";

output += listitems(x).getAttributeNode("ImageUrl").text;

output += "' border=0 hspace=5 alt='Icon'>";

output += "</a>";

output += "</td>";

output += "<td class='ms-vb2' valign='top'>";

output += "<a href='" +
listitems(x).getAttributeNode("DefaultViewUrl").text + "'>";

output += listitems(x).getAttributeNode("Title").text;

output += "</a>";

output += " (" + listitems(x).getAttributeNode("ItemCount").text +
")";

output += "</td>";

output += "</tr>";

}



//Display table

var table = "";

table = "<table border='0' width='100%' cellpadding='2' ";

table += "cellspacing='0' class='ms-summarystandardbody'
rules='rows'>" ;

table += output;

table += "</table>";

txt.innerHTML = table;

}



function getServiceResults(url, soap, xml) {

//Send XML packet to web service and return HTTP response text

try {

if (xml.length > 0) {

xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

xmlHttp.open("POST", url, false);

xmlHttp.setRequestHeader("SOAPAction", soap);

xmlHttp.setRequestHeader("Content-Type", "text/xml");

xmlHttp.send(xml);

if (parseInt(xmlHttp.status) == 404) {

return 404;

}

else {

return xmlHttp.responseText;

}

}

}

catch(e) {

alert(e.message);

}

}

</script>

 
Didn't find what you were looking for? Find more on Workflows on a Sub-Site Or get search suggestion and latest updates.




Tagged: