Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How would you get a list of all the possible choices from a choice field (e.g. Task list Priority or Status fields) using javascript client object model?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

You can get this from SP.FieldChoice.get_choices() (SPFieldChoice inherits SPFieldMultiChoice)

To get that object you need to use context.castTo to cast SP.Field to SP.FieldChoice.

// Setup context and load current web
var context = new SP.ClientContext.get_current();
var web = context.get_web();

// Get task list
var taskList = web.get_lists().getByTitle("Tasks");

// Get Priority field (choice field)
var priorityField = context.castTo(taskList.get_fields().getByInternalNameOrTitle("Priority"),

// Call server
context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),
                          Function.createDelegate(this, this.onFailureMethod));  

function onSuccessMethod(sender, args) {
    // Get string arry of possible choices (but NOT fill-in choices)
    var choices = priorityField.get_choices();
    alert("Choices: (" + choices.length + ") - " + choices.join(", "));

function onFailureMethod(sender, args) {
    alert("oh oh!");
share|improve this answer
I didn't even know about context.castTo, this is brilliant. Thanks! –  eirikb Oct 5 '12 at 14:15
The above code needs to have a context.load(priorityField); before the executeQueryAsync! Otherwise you will get a property error when doing the get_choices() –  user16654 Apr 26 '13 at 16:41
You're right user16654, the code need to be used context.load(priorityField); before executeQueryAsync –  tbbt Dec 18 '14 at 3:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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