I need to return value from my getItemData function, like this :
function getItemData(success, error) {
var clientContext = new SP.ClientContext.get_current();
var ListeEtabScol = clientContext.get_web().get_lists().getByTitle('Etablissements Scolaires');
var ItemEtabScol = ListeEtabScol.getItemById(123456);
clientContext.load(ItemEtabScol, 'Title', 'Adresse', 'Commune');
clientContext.executeQueryAsync(
function() { success(ItemEtabScol); }, error
);
}
var test = getItemData(
function(item){
return item.get_item('Adresse'); //this is ok, adress is returned
},
function(sender, args){
alert('Erreur : ' + args.get_message());
}
);
console.log(test); //test is undefined :-( what's wrong ???
but my test variable is ever undefined. Any idea of my mistake ?
Thanks in advance!