Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Lists.asmx with a lookup field

  Asked By: Chaim    Date: Mar 29    Category: Sharepoint    Views: 5911

I've been beating my head against my desk for hours here. I build a CAML
string and send it to a modified Events list to add items. Everything is
working except the Project Name (which is a lookup field from another
list). I've attached the offending line of code. If I comment this line out
the update works great (with no Project Name)

sUpdateCAML += "<Field Name=\"Project_x0020_Name\" Type=\"Lookup\">9087;
#ID</Field>";

The Result I get back is
<Result ID="1,New"
xmlns="http://schemas.microsoft.com/sharepoint/soap/"><ErrorCode>0x80020005</Err\
orCode><ErrorText>The
operation failed because an unexpected error occurred. (Result Code:
0x80020005)</ErrorText></Result>

So, does anyone have some sample code to add data to a lookup field via
Lists.asmx?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Victoria Bell     Answered On: Mar 29

A few things …

1) Use System.Text.StringBuilder rather than string concatenation to build  up your CAML. Concatenating large strings does bad things to the memory. (Each string is a new object each progressively larger than the last.)

2) Have you verified that Project name’s interna, name is really Project_x0020_Name? This wouldn’t always be the case – particularly if the field  was renamed.

3) The syntax for a lookup  field appears to be … Row ID;#Value … where RowID is the ID of the row (this appears correct) and Value is the value of the selected lookup field in that row. It looks like you gave it back the field name and not the value of the field in that row. If you’re using ID I believe the syntax would be 9087;#9087

FYI, I spent a lot of time over the last few years working with Workers Compensation organizations… I’m continuously reminded of what a small world it is.

 
Didn't find what you were looking for? Find more on Lists.asmx with a lookup field Or get search suggestion and latest updates.




Tagged: