If you are developing SharePoint you just can’t get around JQuery and the marvelous SPServices. Especially if you are dealing with SharePoint Web Services.
There are many hits on the internet if you type in these 2 keywords. But nevertheless there are very few post explaining you how to and which approach and tools can help you in your project.
Let’s say you you want to retrieve some Document ID’s & Names from documents linked into a list Form Body Text.
$(document).ready(function(){ $.fn.SPServices({ operation: "GetListItems", async: false, webURL: "/webs/sitecollection/site", listName: "YourListName", CAMLViewFields: "", CAMLQuery: "1503", completefunc: function (xData, Status) { // Debug //alert(xData.responseText); var liHtml = "" $(xData.responseXML).SPFilterNode("z:row").each(function() { // $("#tasksUL").text(xData.responseText); // Debug info liHtml = "</pre> <ul> <li>" + $(this).attr("ows_FileLeafRef") + "</li> </ul> <pre> "; $("#tasksUL").append(liHtml); }); } }); });</pre> <ul id="tasksUL"></ul> <pre>
The code above will do so. But the mystery is which is the ”ows_xxx” XML attributes you are looking for to get the File Name appearing in your Form.
Solution :
Uncomment this section in the code :
$(“#tasksUL”).text(xData.responseText);
And comment this line :
// liHtml = “<li>” + $(this).attr(“ows_FileLeafRef”) + “</li><br/>”;
This will retrieve the bare output of the return SOAP Envelope in your form.
You can select it out of your Form, and paste it in for example XML Notepad.
It’s got some millage but still going strong.
Here you can see all the Nodes and Attributes in the tree structure.
The one we are interested in is the attribute ows_FileLeafRef in the node z:row
That’s where the document ID and Name appears in.
Once we use that in our code, the result is looking good.
I got the 2 document references from a Document Library somewhere else in SharePoint using SP Web Services !
Hopefully this can clear some mist on how to get all the missing mystery information and parameters correct.