1

How to get ErrorCode value using jQuery from bellow SPServices xml response:

<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
 <Result ID="1,Update">
  <ErrorCode>0x00000000</ErrorCode>
  <z:row ows_ID="4" ows_Title="Title" 
     ows_Modified="2003-06-19 20:31:21" 
     ows_Created="2003-06-18 10:15:58" 
     ows_Author="3;#User1_Display_Name" 
     ows_Editor="7;#User2_Display_Name" ows_owshiddenversion="3" 
     ows_Attachments="-1" 
     ows__ModerationStatus="0" ows_LinkTitleNoMenu="Title" 
     ows_LinkTitle="Title" 
     ows_SelectTitle="4" ows_Order="400.000000000000" 
     ows_GUID="{4962F024-BBA5-4A0B-9EC1-641B731ABFED}" 
     ows_DateColumn="2003-09-04 00:00:00" 
     ows_NumberColumn="791.00000000000000" 
     xmlns:z="#RowsetSchema" />
</Result>
<Result ID="2,Update">
  <ErrorCode>0x00000000</ErrorCode>
  <z:row ows_ID="6" ows_Title="Title" 
     ows_Modified="2003-06-19 20:31:22" 
     ows_Created="2003-06-18 19:07:14" 
     ows_Author="2;#User1_Display_Name" 
     ows_Editor="6;#User2_Display_Name" ows_owshiddenversion="4" 
     ows_Attachments="0" ows__ModerationStatus="0" 
     ows_LinkTitleNoMenu="Title" 
     ows_LinkTitle="Title" ows_SelectTitle="6" 
     ows_Order="600.000000000000" 
     ows_GUID="{2E8D2505-98FD-4E3E-BFDA-0C3DEBE483F7}" 
     ows_DateColumn="2003-06-23 00:00:00" 
     ows_NumberColumn="9001.00000000000000" 
     xmlns:z="#RowsetSchema" />
  </Result>

</Results>
2

If you want to iterate through the results looking for any errors, then use something like this:

var xml = $($.parseXML( yourXMLstring ));
var errors = xml.find("ErrorCode");
for (var i=0; i<errors.length; i++)
{
  alert( "Error for '" + errors[i].parentNode.getAttribute("ID") + 
         "' = " + errors[i].textContent );
}
1

In SPServices CRUD Operations you could do like bellow code to check your operation completed successfully or not if you get the error code value: 0x0000000 it means your operation completed successfully without error.

  $().SPServices({
        operation: "UpdateListItems",
        batchCmd: "New",
        listName: "YourListName",
        valuepairs: [["PersonnelID",PersonalId],["ETA",SetNullDates(ETA)]],
        completefunc: function (xData, Status) {

                        var $xml= $(xData.responseText);
                        var ErrorVal = $xml.find("ErrorCode").text();
                        if(ErrorVal=="0x00000000")
                        {
                            alert("Operation Success");
                            //-----Display a message that operation is success
                        }
                        else
                        {
                            alert("Un Expected Error Occurred, Please contact SharePoint Admins");
                        }
            }
        });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.