#StackBounty: #powershell #csom #project-server Get Selection from Lookup Table CSOM PowerShell in Project Server

Bounty: 50

I have a custom field at the project level that is a lookup table (single select). I cannot for the life of me figure out how to get the value of the selection from the lookup table. I can get the lookup table:

$lookupTables = $projContext.LookupTables
$projContext.Load($lookupTables)
$projContext.ExecuteQuery()

$myLookupTable = $lookupTables.GetByGuid('GUID FOR LOOKUP TABLE')
$projContext.Load($myLookupTable)
$projContext.ExecuteQuery()

and I can get the field:
$custFields = $project.CustomFields
$projContext.Load($custFields)
$projContext.ExecuteQuery()

$myField = $custFields.GetByGuid([Guid]"{GUID FOR FIELD}") 
$projContext.Load($myField )
$projContext.ExecuteQuery()

When I look at values in myField everything looks ok. I can see the .LookupDefaultValue but when I try to get the selection of the Field, I’m not quite sure what to do. I’ve Tried:

$myfieldvalue = new-object Microsoft.SharePoint.Client.FieldUserValue($myField).LookupValue

But it comes out as Microsoft.SharePoint.Client.FieldUserValue

I’ve tried

$myfieldvalue = $myField .Value
$projContext.Load($myfieldvalue )
$projContext.ExecuteQuery()

but that blows up on the Load.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.