2

I have a sharepoint list and I want to set some value inside it. The multi-choice field is already defined and it is already pointing on data. I just want to pick one of the choices and set it in the field. I don't want to create new values and adding them inside.

    $weburl = "http://sdfsdfsdf"
    $web = Get-SPWeb $webUrl
    $list=$web.GetList("/Lists/ListName")

    $choice = # what do i have to put here ?

    $newItem = $list.AddItem()
    $newItem["multiChoiceField"] = $choice
    $newItem.update()
  • have you had any luck on this, currently trying to figure out the same – Brent Ellis Mar 19 '15 at 18:27
1

from msdn:

$choicevalues = New-Object Microsoft.SharePoint.SPFieldMultiChoiceValue;
$choicevalues.Add("Green");            
$choicevalues.Add("Blue");            
$i["multiplechoicefield"] = $l.Fields["multiplechoicefield"].ParseAndSetValue($i,$choicevalues);            
$i["multiplechoicefield"].ToString();            
$i["multiplechoicefield"] = $choicevalues;            
$i.Update();            
#-or-            
$l.Fields["multiplechoicefield"].ParseAndSetValue($i,$choicevalues);            
$i.Update();
  • 1
    Thank you for your answer. I already have seen this piece of code and it didn't fixed my problem. Plus, as I said I don't want to create new values because they already exist. – ameliapond Feb 26 '15 at 16:30
0

May have stumbled upon it, in Powershell, I have an actual array variable of values

$languages = Eng,Fr,Sp

I set my field to equal this array:

$NewItem["TestLanguages"] = $languages

Spent forever trying to do what was listed above as well, but this is working for me (and so simple too)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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