2011-08-05 17 views
0

リストWebサービスで "UpdateListItems"メソッドを使用してSharePointリストアイテムを更新しようとしています。 CAMLクエリ:SharePointリストアイテムを使用してリストアイテムを更新する

"<Method ID='1' Cmd='Update'>" + 
      "<Field Name='ID'>" + itemID + "</Field>" + 
      "<Field Name='Status'>" + itemStatus + "</Field></Method>" 

ITEMID、itemStatusおよびパラメータとしてUIから渡されました。 これは次のエラーを表示します

<Result ID="1,Update"> 
<ErrorCode>0x80070005</ErrorCode> 
<ErrorText>The operation failed because an unexpected error occurred. (Result Code: 0x80070005) 
</ErrorText> 
</Result> 

いずれかを助けてください。 さらにもう1つの質問は、IDに基づいてのみ更新メソッドが機能するか、またはTitleを渡す可能性があることです。

おかげ

答えて

1

ます。ただし、これは同じ問題に直面して、他の誰かのために役立つかもしれない、この時点では必要ないかもしれません。

場合によっては、このエラーの原因はSOAPアクションのヘッダーです。あなたは更新を行うために以下を設定する必要があります。:

beforeSend:function(xhr){xhr.setRequestHeader( "SOAPAction"、 "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");

私はSharePointリストで更新を送信するには、次の関数を作成しました:

function sendupdates(location,listName,command,fieldnames,fieldvalues){ 
     var updatesvar; 
     for(x=0;x<fieldnames.length;x++){ 
     updatesvar = updatesvar + '<Field Name="'+fieldnames[x]+'">'+fieldvalues[x]+'</Field>' 
     } 

     var batchvar = '<Batch OnError="Continue" ListVersion="0"><Method ID="1" Cmd="'+command+'">'+updatesvar+'</Method></Batch>'; 

     var soapEnv = 
        '<?xml version="1.0" encoding="utf-8"?>'+ 
        '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+ 
        '<soap:Body>'+ 
        '<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'+ 
        '<listName>'+listName+'</listName>'+ 
        '<updates>'+batchvar+'</updates>'+ 
        '</UpdateListItems>'+ 
        '</soap:Body>'+ 
        '</soap:Envelope>'; 

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

    } 
関連する問題