3

I've recently discovered that the Lists.asmx ignores your attempts to reset a field's value to empty string or null with Lists.UpdateListItems. Not a very well documented limitation discovered by trial and error.

Can someone advise on the possibility to reset field values using FP RPC / OWSAPI from AJAXy pages? Or am I missing something in the OOTB web service functionality / CAML syntax? I mean without deploying a custom Web Service just for that little generic task?

4
  • I tried <Field></Field> and for lookups <Field>0;#</Field> and <Field>;#</Field>. To no avail. Both via AJAX calls and via u2u CAML Query Builder. I'm now looking into owsvsvr.dll calls which may be what DataView WebPart and SPD do. May 20, 2010 at 19:40
  • Have you tried using a variable set to null or empty? May 22, 2010 at 20:19
  • Where exactly? I'm not aware of a way to reference null-valued client side variables via SOAP XML-based request other than just <Field Name='' /> May 23, 2010 at 23:45
  • Well I think I'd like to revive this discussion. Let's start a bounty. Jun 27, 2011 at 14:27

2 Answers 2

4
+50

I just did a test with SPServices where I set a Single line of text column to an empty string (""), which seemed to work just fine. This was with WSS 3.0 (the simplest test case, IMO).

  $().SPServices({
    operation: "UpdateListItems",
    async: false,
    debug:true,
    listName: "Sales Opportunities",
    ID: 5,
    valuepairs: [["StateID", ""]],
    completefunc: function (xData, Status) {
      alert(xData.responseText);
    }
  });

This generates the call:

<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>Sales Opportunities</listName>
      <updates>
        <Batch OnError="Continue">
          <Method ID="1" Cmd="Update">
            <Field Name="StateID"></Field>
            <Field Name="ID">5</Field>
          </Method>
        </Batch>
      </updates>
    </UpdateListItems>
  </soap:Body>
</soap:Envelope>

EDIT:

I just did the same thing for a Lookup column and a Person or Group column. The valuepairs line is:

valuepairs: [["State", ""], ["Sales_x0020_Rep", ""]],

Both columns were "emptied".

3
  • OK, how about a lookup field? Jun 27, 2011 at 20:16
  • +1, just sending <Field Name="LookupField"></Field> seems to work fine.
    – Kit Menke
    Jun 28, 2011 at 14:33
  • Yay! I got 50 points. I'll go buy something with them right away. ;+) Jun 29, 2011 at 16:36
0

In the end, had to resort to writing a custom web service that also makes great bandwidth savings.

1
  • But that's not the definitive answer to my own inquiry whether or not there IS a way to reset a field value to null. Jun 27, 2011 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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