Lookup cannot get extra values unless selected

Hello,

I have scenario where on Change lookup field (lookupcontrol01) i am filling another controls data from this lookup, one of these controls is a lookup field (lookupcontrol02).
my problem within the same function i am filling more controls from (lookupcontrol02).

(lookupcontrol02) is getting value but i can't fill other controls from this lookup extra fields unless i select (lookupcontrol02) (Trigger)
i am gettimng undefined after debugging
are there any syntax or script it help to assure that a lookup control is getting values in order to access the lookup extra fields.

Fucntion:

//Set parish Data on change
function SubProcSetCtrlFromParish() {
    //This is the first Lookup Control (LookupControl01)
    fd.field("PersonAddressParishIDfk").ready().then(function () {
        //This is the Second Lookup Control (LookupControl02)
        return fd.field("PersonAddressTown").ready();
    }).then(function () {
        debugger;
        //This is the Second Lookup Control filled from (LookupControl01)
        fd.field('PersonAddressTown').value = fd.field('PersonAddressParishIDfk').value.ParishVillage.Id;
        //another control is field from (LookupControl01) 
        fd.field('PersonAddressParishText').value = fd.field('PersonAddressParishIDfk').value.ParishName;
        //attempting to fill more controls from (LookupControl02) 
        //But i am not  getting values unless i select the lookup manually
        fd.field('PersonAddressProvince').value = fd.field('PersonAddressTown').value.VillageCaza.CazaName;
        fd.field('PersonAddressCaza').value = fd.field('PersonAddressTown').value.Province.ProvinceName;
    });
}
//Parish Lookup value on change
fd.field('PersonAddressParishIDfk').$on('change', SubProcSetCtrlFromParish);

note that i already added the fields needed as extra fields and expand
but is not working by JS code, unless the lookup and requested value is selected (trigger) by mouse.

kindly any solution.

Hello @gkhadra,

Unfortunately, extra fields are only retrieved on change, so you can't get them with your code.

You can get item values using pnpjs. Please see the example with filtering below and also have a look at this article.

pnp.sp.web.lists.getByTitle("ListName").items.filter("ID eq '2'").get().then(function(items) {

                console.log(items[0].Title);
   });

Dear @mnikitina,

I am already using pnpjs in order to get values
i taught maybe there is something easier, however thank you for your reply

1 Like