I'm trying to retieve a choice value that a user has selected from a dropdown list with :

var oTextColour=oListItem.get_item('myChoice');

But I got null when alerting the value.

I have tried :

var oTextColour=oListItem.get_item('myChoice').get_lookupValue(); but this errors.

Any ideas, using javascript ?

More Code

function retrieveListItemsAU() {

   var clientContext = new SP.ClientContext();  
   var oList = clientContext.get_web().get_lists().getByTitle("AboutUs");  
   var camlQuery = new SP.CamlQuery();

camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='_ModerationStatus'/><Value Type='ModStat'>0</Value></Eq></Where></Query></View>"); 
this.collListItemAU = oList.getItems(camlQuery);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededAU), Function.createDelegate(this, this.onQueryFailedAU));        


function onQuerySucceededAU(sender, args) {

        var listItemInfo = '';
        var table = '';
        var image='';
        var lookupVal='';

        var listItemEnumerator = collListItemAU.getEnumerator();

while (listItemEnumerator.moveNext()) {

    var oListItem = listItemEnumerator.get_current();
    var oTitle=oListItem.get_item('Title');
    var oDescIntro=oListItem.get_item('Introduction');

    //var oTextColour=oListItem.get_item('myChoice');
//alert (oTextColour);

} // end while loop

} // end function
  • Can you show us more code? – wjervis Mar 4 '15 at 13:32
  • Added more code. Title and Introduction outputs okay, just the choice that doesnt. – Orange Juice Jones Mar 4 '15 at 15:44
  • That's odd, should work. Have you tried to specifying the columns to include in the load? clientContext.load(collListItemAU, 'Include(Title, Introduction, myChoice)') – wjervis Mar 4 '15 at 17:35

Just realised the list was not saving the column, it appeared to when I selected the Edit column, data was present on the infopath form. I added the column later and I needed to toggle the data.


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.