Multiple lookup extrafields

Good day,
I have i multiple choice lookup. I need extrafields of all values selected in this lookup.
i tried from manual, added extrafields name in lookup properties.

//alerts all values as a text string
var selected = fd.field('LookupMulti').value;
var s = '';
for (var i = 0; i < selected.length; i++) {
    s += selected[i].LookupValue + '; ';
}
alert(s);

But it works only for lookup values . but i need values of extrafields.

my code:

fd.spRendered(function () {
    function Store(){
        if (fd.field('Sucursale_x0020_adresate').value)
 fd.field('Sucursale_x0020_adresate').ready().then(function(field) {
 console.log(field.value)
   // alert(field.value.Cod_x0020_Subdiviziune);
	var selected = fd.field('Sucursale_x0020_adresate').value.Cod_x0020_Subdiviziune;
  });
//alert(fd.field('Sucursale_x0020_adresate').value.ManagerIMM)
//fd.field('cat').value=fd.field('Sucursale_x0020_adresate').value.Cod_x0020_Subdiviziune;
var selected = fd.field('Sucursale_x0020_adresate').value.Cod_x0020_Subdiviziune;
var s = '';
for (var i = 0; i < selected.length; i++) {
s += selected[i].LookupValue + ';';
console.log('s='+s)
}
//Set field values with the values from the parent on form load
fd.field('cat').value = s;

}
fd.field('Sucursale_x0020_adresate').$on('change', Store);
//Store();
});

and i get error

Dear @ixxxl,
You are not changing it in the right place.

If you want some other field, for example, Title, you can get it this way:

//alerts all values as a text string
var selected = fd.field('LookupMulti').value;
var s = '';
for (var i = 0; i < selected.length; i++) {
    s += selected[i].Title + '; ';
}
alert(s);

PS. Please, note that the extra fields are only available after change. They aren't available on load, if you want them on load as well - you might want to store them in some other hidden field or retrieve dynamically with pnpjs.

1 Like

@Nikita_Kurguzov
Super!! Thanks! works as i want!