0

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.load(collListItemAU);
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
3
  • Can you show us more code?
    – wjervis
    Commented Mar 4, 2015 at 13:32
  • Added more code. Title and Introduction outputs okay, just the choice that doesnt. Commented Mar 4, 2015 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
    Commented Mar 4, 2015 at 17:35

1 Answer 1

0

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.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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