Wednesday, September 19, 2012

JQuery: Read list Item via Lists.asmx

Following JQuery script is to get list items using Lists.asmx web service in MOSS 2007:
<script type="text/javascript" src="/Scripts/jquery-1.8.1.min.js"></script>
<script type="text/javascript">

//This function will call when OK button will be pressed on a List's default form (e.g. EditItem.aspx).

function PreSaveItem()
 var project = "Project A";
 return true;

function GetProjectID(project){

var soapEnv = "<soap:Envelope xmlns:soap=''> \
<soap:Body> \
    <GetListItems xmlns=''> \
        <listName>Teams</listName> \
        <query><Query><Where><Eq><FieldRef Name='Project'/><Value Type='Text'>"+ project +"</Value> </Eq></Where></Query></query> \
        <viewFields> \
            <ViewFields> \
                <FieldRef Name='ID' /> \
                <FieldRef Name='Title' /> \
            </ViewFields> \
        </viewFields> \
        <rowLimit>99999</rowLimit> \
        <queryOptions xmlns:SOAPSDK9='' ><QueryOptions/> \
        </queryOptions> \
    </GetListItems> \
</soap:Body> \

url: "/itsglobal/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: ResultMethod,
contentType: "text/xml; charset=\"utf-8\""


function ResultMethod(xData, status) 

    if (status=="success")


I have copied this script from the internet and have tweaked it a bit to work with JQuery 1.8 version.

No comments:

Post a Comment

Official SharePoint Documentation

I have recently contributed to the official SharePoint documentation for developement. Check it out here: