Lists Web Service UpdateList fails with "Attempted to use an object that has ceased to exist"

4

SharePoint 2010 Lists Web Service UpdateList fails with "Attempted to use an object that has ceased to exist"...but it DOES exist.

I would like to update an attribute for existing fields. For demonstration purposes, it should be easy to update Description. Using and extending haufe.sharepoint 0.1.9, I am able to query/update items and delete fields. I am confident I am correctly addressing the list having observed changes during update and delete. I believe the field is also accurately addressed because a) it can be deleted and b) if I change the “Name” or “ID”, the error changes to “Field with that name was not found”.

Dumping the SOAP message from SUDS, I can show the different messages and results. Three test cases are shown below. The first is the failure. The second shows a mismatched name results in a different error. The third shows how to delete the field by Name.

Any ideas on where to go next? Might there be a special permission to update a field beyond being able to delete that same field? Although I am subsite owner, I am not a SharePoint admin or server admin. So, looking at logs or installing custom code is difficult/out. That’s why I’m using a Python web service approach. I am nearly completely stumped.

Thanks, Rob

Message: This should work to update the field “Description” but does not. In addition to using the field ID, I’ve tried the Name, DisplayName, and StaticName to no avail. MSFT reference is: http://msdn.microsoft.com/en-us/library/lists.lists.updatelist%28v=office.12%29.aspx

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:UpdateList>
         <ns1:listName>D538A29D-6DD4-423A-9E7D-2697917BDA78</ns1:listName>
         <ns1:updateFields>
            <Fields>
               <Method ID="1">
                  <Field ID="08d8fb05-0de8-4e19-988c-e204ade07f47" Description="new desc"/>
               </Method>
            </Fields>
         </ns1:updateFields>
      </ns1:UpdateList>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Fault is:

<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring>
<detail>
<errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))</errorstring>
<errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x80030102</errorcode>
</detail>
</soap:Fault>

Message: Expecting not to find the field and did not. Basically, this proves an incorrect name results in a different error.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:UpdateList>
         <ns1:listName>D538A29D-6DD4-423A-9E7D-2697917BDA78</ns1:listName>
         <ns1:updateFields>
            <Fields>
               <Method ID="1">
                  <Field ID="q08d8fb05-0de8-4e19-988c-e204ade07f47" Description="new desc"/>
               </Method>
            </Fields>
         </ns1:updateFields>
      </ns1:UpdateList>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Message: Able to delete the field like this. This just proves the field can be manipulated in some way successfully.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:UpdateList>
         <ns1:listName>D538A29D-6DD4-423A-9E7D-2697917BDA78</ns1:listName>
         <ns1:deleteFields>
            <Fields>
               <Method ID="3">
                  <Field Name="myText"/>
               </Method>
            </Fields>
         </ns1:deleteFields>
      </ns1:UpdateList>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
python
sharepoint-2010
suds
asked on Stack Overflow Nov 22, 2012 by QuidScio

1 Answer

2

This works

Progress made for updating and adding fields! "Fragile" comes to mind as a way to describe the Lists.asmx web service. Notably, Field attributes are order dependent; Type needs to come first - guess maybe there's a wacky "if-tree" in Microsoft's code. In addition, DisplayName is required followed by Name if there might be ambiguity using only DisplayName.

The key debugging trick models a programatically added field after a similar, GUI added, field. To discover proper parameters:

  1. Create a similar field thru the GUI
  2. Set suds logging to debug level.
  3. Open list using haufe.sharepoint's "service = Connector(url, username, password, list_id)" and examine the returned SOAP message for the field's parameters.
  4. Use these attributes to drive the experimentation keeping in mind some fields are read-only or otherwise not intended for external use as defined by Microsoft.

Following are four success examples for updating a text field, updating a calculated formula field, adding a text field, and adding a calculated field. Hopefully this is enough for me and others to build on. Note: haufe.sharepoint does not support these additional methods or return of the results. So...some hacking is required.

Update a text field

Type must be first attribute. Use DisplayName followed by Name to avoid ambiguity with other fields.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:UpdateList>
         <ns1:listName>D538A29D-6DD4-423A-9E7D-2697917BDA78</ns1:listName>
         <ns1:updateFields>
            <Fields>
               <Method ID="1">
                  <Field Type="Text" Name="myText" DisplayName="myText" Description="new desc"/>
               </Method>
            </Fields>
         </ns1:updateFields>
      </ns1:UpdateList>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Update a calculated field

Type must be first attribute. Use DisplayName first and then Name to avoid ambiguity with other fields.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:UpdateList>
         <ns1:listName>D538A29D-6DD4-423A-9E7D-2697917BDA78</ns1:listName>
         <ns1:updateFields>
            <Fields>
               <Method ID="1">
                  <Field Type="Calculated" DisplayName="myCalcAdd" Name="myCalcAdd" ResultType="Number" ReadOnly="TRUE">
                     <Formula>=Jan*0.5</Formula>
                     <FormulaDisplayNames>=Jan*0.5</FormulaDisplayNames>
                     <FieldRefs>
                        <FieldRef Name="Jan"/>
                     </FieldRefs>
                  </Field>
               </Method>
            </Fields>
         </ns1:updateFields>
      </ns1:UpdateList>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Add text field

Type must come first. DisplayName vs Name seems to be the more important of the two attributes.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:UpdateList>
         <ns1:listName>D538A29D-6DD4-423A-9E7D-2697917BDA78</ns1:listName>
         <ns1:newFields>
            <Fields>
               <Method ID="1">
                  <Field Type="Text" Name="myTextAdd" DisplayName="myTextAdd" Description="My first added field"/>
               </Method>
            </Fields>
         </ns1:newFields>
      </ns1:UpdateList>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Add calc field

Type must come first. DisplayName is needed while Name is not. ResultType is also required at least in the case below.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns1:UpdateList>
         <ns1:listName>D538A29D-6DD4-423A-9E7D-2697917BDA78</ns1:listName>
         <ns1:newFields>
            <Fields>
               <Method ID="1" AddToView="">
                  <Field Type="Calculated" DisplayName="myCalcAdd" ResultType="Number">
                     <Formula>=Jan*0.5</Formula>
                     <FormulaDisplayNames>=Jan*0.5</FormulaDisplayNames>
                     <FieldRefs>
                        <FieldRef Name="Jan"/>
                     </FieldRefs>
                  </Field>
               </Method>
            </Fields>
         </ns1:newFields>
      </ns1:UpdateList>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
answered on Stack Overflow Nov 25, 2012 by QuidScio • edited Nov 25, 2012 by QuidScio

User contributions licensed under CC BY-SA 3.0