views:

263

answers:

1

Hi

Can I update a sharepoint list item using list webservice updatelistitem method's field title instead of field Id. for eg: msdn sample uses Field Name ID batchElement.InnerXml = "" + "6" + "Modified sixth item" + "7" + "Modified seventh item" + "5" + "" + "Added item"

Since I am pulling the information from sql db to update the list and I dont know the item id, can i use title as condition to update the other item fields?

  • Gane
A: 

Are you querying gthe sharepoint database when you say " I am pulling the information from sql db"? If so don't. If not and you are using an external db in which you store an item's title, you probably need to do a call to the same service's GetListItems method, using a query the returns items based on the Title field. The query would be something like so:

<Query>
  <Where>
    <Eq>
      <FieldRef Name='Title' />
      <Value Type='Text'>Title of item</Value>
    </Eq>
  </Where>
</Query>

or, if you need more, nest the Eq elements in OR's like so

<Query>
  <Where>
    <Or>
      <Or>
        <Eq>
          <FieldRef Name='Title' />
          <Value Type='Text'>Title of item</Value>
        </Eq>
        <Eq>
          <FieldRef Name='Title' />
          <Value Type='Text'>Other Title of item</Value>
        </Eq>
      </Or>
      <Eq>
        <FieldRef Name='Title' />
        <Value Type='Text'>Yet another Title of item</Value>
      </Eq>
    </Or>
  </Where>
</Query>

Then use the ID's in the result of this call to build your batch xml.

Colin
I am getting information from an external db. I was wondering can I do a web service batch update a sharepoint list using title, instead of ID. Otherwise I need to query the list using your method above to get the ID for the title or so.
Gane

related questions