更新Sharepoint列表项

时间:2016-04-18 11:07:24

标签: jquery sharepoint-2013 spservices

我正在尝试使用下面提到的代码更新列表项

var soapEnv="<?xml version='1.0' encoding='utf-8'?> \
<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'> \
    <soap12:Body> \
        <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
            <listName>TestList</listName> \
                <updates> \
                    <Batch OnError='Continue'> \
                        <Method ID='1' Cmd='Update'> \
                            <Field Name='RoleAsignedToSkill'>"+align+"</Field> \
                            <Field Name='CrossCapability'>"+ccap+"</Field> \
                            <Field Name='CrossSpecialty'>"+cspcl+"</Field> \
                            <Field Name='CrossSkill'>"+cskill+"</Field> \
                            <Field Name='SuggestedTraining'>"+st+"</Field> \
                            <Field Name='ToCrossSkill'>"+tcs+"</Field> \
                            <Field Name='Status'>Done</Field> \
                            <Field Name='ID'>"+rid+"</Field> \
                        </Method> \
                    </Batch> \
                </updates> \
        </UpdateListItems> \
    </soap12:Body> \
</soap12:Envelope>";    

$.ajax({
url: "https://test.com/sites/test/_vti_bin/lists.asmx",
beforeSend: function (xhr) {
    xhr.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
},
type: "POST",
dataType: "xml",
data: soapEnv,
contentType: "text/xml; charset=\"utf-8\""  });

列表中的所有列都是“单行文本”,最大字符集为255。 现在的问题是,如果我发送30个字符长度的数据,那么数据会得到更新,但如果不是更新的话。请帮忙

1 个答案:

答案 0 :(得分:0)

我从未使用批处理模式。但请检查此链接:Field Element in Batch

属性类型是必需的。可以使用“文本”类型(对应于单行文本)

喜欢:

var soapEnv=" ....
              .....
             <Field Name='RoleAsignedToSkill' Type='Text'>"+align+"</Field> 
            .....