jeudi 5 mars 2015

retrieve choice value with jsom



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



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


But I get null when alerting the value.


I've 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







0 commentaires:

Enregistrer un commentaire