This project has moved and is read-only. For the latest updates, please go here.


Jun 27, 2011 at 7:06 PM


  I cannot find a way using NameValue Pairs to create a listitem that has a lookupfield.  There is no place to put the  Type='Lookup' in the value pair.  I tried CAML Query but I never connected to SP Web Service.  I kept checking status and getting "Error" without any other information.



Jun 27, 2011 at 7:24 PM

You need to pass in the value which a Lookup column would contain. This *generally* looks like:

1;#Text value

where 1 is the ID of the lookup value in the source list and "Text value" is the actual value of the source column.


Jun 28, 2011 at 11:32 AM
Edited Jun 28, 2011 at 11:35 AM

I tried  valuepairs: [["ReservedBy","1;#John Doe"],["Resource","1;#Toothbrush"]],

but still receive the error from UpdateListItem web service:

>Exception: Index and length must refer to a location within the string,  Paramater name: length&lt;BR&gt;</errorstring>


If I take the lookup out then the message is replaced by

"Object reference not set to an instance of an object"

I assume because the required fields are missing.

Jun 28, 2011 at 1:35 PM

I just tried this code, which works. Note that the State column in Sales Opportunities is a Lookup column to the Title column in a list called States.

    operation: "UpdateListItems",
    async: false,
    listName: "Sales Opportunities",
    ID: 5,
    valuepairs: [["State", "2;#Rhode Island"]],
    completefunc: function (xData, Status) {
} });

It also seems to work fine if I just specify the index:

valuepairs: [["State", "3"]],

In this case, 3 is California, and it is set correctly.

In your example above, you have two columns: Resource may be a Lookup column, but ReservedBy looks to be a Person or Group column.

I'm also able to update a Person or Group column using just the index:

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

I'd try isolating the two updates to see if you can get each to work individually.


Jun 28, 2011 at 1:55 PM
Edited Jun 28, 2011 at 1:57 PM

Yes, it is a person/group.  I will try your example it a while.  I reverted to using CAML until I get more time to explore this.  Thanks for the help. 

Jun 28, 2011 at 1:58 PM
What version of SPServices are you using?

Jun 28, 2011 at 3:28 PM
Edited Jun 28, 2011 at 3:34 PM



I am upgrading to 0.6.2 and giving it a try.

Jun 28, 2011 at 3:41 PM

There was a fix in 0.6.2 to encode some characters with the valuepairs approach, so that might be why you're seeing the issue in 0.6.1. Using just the ID, though, you shouldn't have that issue.

Let me know what you find.


Jul 13, 2011 at 4:29 PM
Edited Jul 13, 2011 at 4:29 PM

0.6.2 fixes the problem.  Sorry for not getting back sooner.