How I created a “Copy to new item” functionality for a SharePoint list – Part 2

Second part. First Part can be found here. On the second page (NewForm.aspx), I grabbed out of the querystring the values for the source list item and the name of the list.
I used this person’s query string parser.

Then I used the following SOAP query :

$(document).ready(function() {
 var sourceID = getQuerystring('SourceID');
 var listName = getQuerystring('ListName');

 var soapEnv = "<soapenv:Envelope xmlns:soapenv=''> \
<soapenv:Body> \
<GetListItems xmlns=''> \
<listName>" + listName + "</listName> \
<viewName>{GUID}</viewName> \
<viewFields /> \
<ViewFields /> \
<query> \
<Query><Where> \
<Eq> \
<FieldRef Name='ID' /> \
<Value Type='Integer'>" + sourceID + "</Value> \
</Eq> \
</query> \
</GetListItems> \
</soapenv:Body> \

 async: false,
 url: "",
 type: "POST",
 dataType: "xml",
 data: soapEnv,
 complete: processResult,
 contentType: "text/xml; charset=\"utf-8\""

 function processResult(xData, status) {
 $(xData.responseXML).find("z\\:row").each(function() {
 $("select[title='DropDown']").val($(this).attr("ows_DropDown")).attr("selected", "selected"); 

In the last three lines I changed the input box, textbox and dropdown boxes to their values in the results fromt the SOAP query.

Kinda fun. Just need to figure out how to do check boxes!


Comments are closed.

Powered by WordPress. Designed by WooThemes