WebUrl and valuepairs

Nov 13, 2009 at 2:55 PM

Hi,

I tried out this library and ran into two issues I hope someone can help with.

1. How do I use the valuepairs option for "UpdateListItem"? I need to add two fields in the option "valuepairs" and was not able to get the syntax right.

2. I wanted to use the "UpdateListItems" method on a sub site, so I added the webUrl option with value http://servername/subsite/. But when using Fiddler reports that the "UpdateListItem" method is using "/_vti_bin/lists.asmx" and not "/subsite/_vti_bin/lists.asmx" and I get an error about not finding the list. I think it worked with the "GetList" method.

Keep up the good work.

Regards,

// Henrik

Coordinator
Nov 13, 2009 at 3:52 PM

Henrik:

I definitely need to get some documentation in for the valuepairs option.  It's meant to be a shortcut rather than using the CAML syntax, but without documentation, not so helpful.  The way it works is that it lets you specify an array of column StaticNames and values.  So if you wanted to update the Title and the Body:

valuepairs: [["Title", "New Title Value"], ["Body", "Here is a the new text for the body column."]]

All that happens here is that the valuepairs are used to build up the CAML for UpdateListItems rather than requiring you to specify the full CAML syntax, which in this case would be:

<Batch OnError='Continue'>
  <Method ID='1' Cmd='Update'>
    <Field Name='Title'>New Title Value</Field>
    <Field Name='Body'>Here is a the new text for the body column.</Field>
    <Field Name='ID'>1234</Field>";
  </Method>
</Batch>

Note that if you decide to use the valuepairs approach, you also need to specify the ID option.  The default for the batchCmd option is 'Update'.

If the list is in the current site, you don't need to specify WebURL; the current site is assumed.  If the list is in another site, then specify it like: /servername/subsite/

M.

Nov 16, 2009 at 7:15 PM

Hi and thanks for the answers.

The valuepair syntax was tricky, I wouldn´t managed to guess it althought I tried alot :) I was trying to locate where the parsing was done but couldn´t find it either.

So skipping the http:// part will solve this, great.

Regards,

// Henrik

Coordinator
Nov 16, 2009 at 7:55 PM
Edited Nov 16, 2009 at 8:30 PM
Sorry about that. Let me know how it goes!
M.