2

There is a custom field in my list called "Solutions". The user can select multiple values for this field (they are in a set of checkboxes on the interface).

I get all the other values in the list with the code item.FieldValues["Solutions"].ToString(); but I'm unable to retrieve the multiple values this way.

Intellisense shows FieldValues as a dictionary entry, with the field name as key and the array as the value, but I can't parse it that way.

I've worked with the SPFieldUserValueCollection, so I know there must be a structure that will parse this out for me, but I can't find it. Can anyone point me in the right direction? Or give me a working example?

4

There is no specific class for storing choice field value like in case of, for example, user field value in CSOM API.

Since multiple choice field value is stored in string array, the following example demonstrates how to retrieve it:

var list = ctx.Web.Lists.GetByTitle(listTitle);
var listItem = list.GetItemById(itemId);
ctx.Load(listItem);
ctx.ExecuteQuery();
var solutions = (string[])listItem["Solutions"];
//or
var solutionsList = new List<string>((string[])listItem["Solutions"]);

foreach (var solutionValue in solutions)
{
    Console.WriteLine(solutionValue);    
}
|improve this answer|||||
  • 1
    Perfect. I hadn't been casting it correctly. – Farducci May 19 '15 at 18:21

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.