Using a Workflow to update a Lookup field in a Library in SharePoint I ran into this error:
Value does not fall within the expected range
I had no issue obtaining the value of a value from the Lookup field.
Dim sString As New SPFieldLookupValue(DirectCast(wfP.Item(“Field-R”), String))
sString= sString.LookupValue
BUT, what I failed to pay attention to was the hyphen in the field name.
Using the U2U CAML Query Builder I discovered my problem.
The real field name was Field_x002d_L
wfP.Item(“Field_x002d_L”) = New SPFieldLookupValue(1, “Value”)
…. Make sure you are updating the correct field name.
code:
spLibItem.Item(sField) = New SPFieldLookupValue(sValueID, sValue)