I have a document library (contact). Have created a custom list (workstatus). Have added column to contact library which is lookup of workstatus.

Below is my code using which i am setting the lookup column value. Unfortunately code runs fine (no exceptions) but when i check in SharePoint value is not set for the given column

FieldLookupValue lvworkstatus = new FieldLookupValue();
lvworkstatus.LookupId = workstatus;
item["crmworkstatus"] = lvworkstatus;

Kindly let me know what is wrong / missing.

  • 2
    What is the value of the workstatus variable? It should be the Id of the ListItem in the workstatus list that you want to associate with the contact. Commented Jul 5, 2015 at 16:13

1 Answer 1


As Rob mentioned, the lookup value must be set by ID

$lookupfield = $l.Fields["lookupfield"] -as [Microsoft.SharePoint.SPFieldLookup];            
$lookuplist = $w.Lists[[Guid]$lookupfield.LookupList];            
$sourcefield =  $lookupfield.LookupField;            
$lookupitem = $lookuplist.Items[0];             
$lookupitem = $lookuplist.GetItemByUniqueId([Guid]"{fc71b84c-74d4-4f7c-9eed-fb7a5fbe24a6}")  
$lookupitem = $lookuplist.GetItemById(1)            
$lookupvalue = New-Object Microsoft.SharePoint.SPFieldLookupValue($lookupitem.ID,$lookupitem.ID.ToString());            
$i["lookupfield"] = $lookupvalue;            

Here is an excellent reference for getting/setting various types in Sharepoint using Powershell:


  • 5
    just an FYI, although you are using the same CSOM, the OP is not for PowerShell. His code is in C#, so it would be easier to follow if you provide answers in the same language as OP or at least acknowledge that your answer accomplishes the same as requested but in different language Commented Sep 27, 2015 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.