Cannot make extra field for lookup populate value

Hello! I read all the documentation and all the discussions here but I still cannot make an extra field work.
In my main list I have a lookup column [Currency] to another list (lookup by Title). In the second list I have a column Rate. I have a Rate column in my main list (number column). I need Rate to be populated with the number from the second list (I need it on New form as I need to do calculation after). This is my script:

fd.spRendered(() => {
    var lookup = fd.field('Currency');

    lookup.extraFields = ['Rate']; // get extra fields
   
    function updateFields() {
        fd.field('Rate').value = lookup.value.Rate;
        
    }

    updateFields(); // update fields on form render
    fd.field('Currency').$on('change', updateFields); // update fields whenever the lookup value is changed
});

And Extra column is set up on the form, what am I doing wrong?

Hi @katy,

The code seems correct. Are there any errors in the browser's console (F12)?

hi @IliaLazarevskii
Yes, here are the console errors (btw: fd.closed has a redirect and works fine despite of the message):

Hello @katy,

The Currency is a Lookup control, so you need to call it with fd.control. Please update the code:

var lookup = fd.control('Currency');

Hello @Margo thank you, i changed that, but still no Rate and here is the error in console:
![

Maybe the issue is that both Rate columns have the same name? Should I rename (recreate) one of them? The Rate in the lookup list is 100% populated

@katy,

What is the type of the Rate column? What is its internal name?

You can check the internal name in the column settings page URL:

If you specify extra fields in the designer interface, you don't need to do that in the code. Remove this line:

lookup.extraFields = ['Rate'];

@Margo Happy New Year :slight_smile: Sorry, we were on a Christmas - New Year break.
In both lists, the internal name of columns is Rate, they are both Number columns.
I removed the line from the code and it is still not showing the value, here is the code now:

fd.spRendered(() => {
    var lookup = fd.control('Currency');

    function updateFields() {
        fd.field('Rate').value = lookup.value.Rate;
    }

    updateFields();
    fd.control('Currency').$on('change', updateFields);
});

I am doing it on a New form and getting this error in the console still:

Dear @katy,
Try to change fd.control('Currency'); to fd.field('Currency'); - we support both fields and controls, but it looks like you're using fields in this case.

Hi @Nikita_Kurguzov , that didn't work either :-(( I already created a new list with only these two fields to test and only this code - still not working. I wonder if I am missing something simple. I can make a video of this issue and send it to you if you could look or we can set up a meeting (during your work hours) as we've bought some service hours with you. What would be the best way?

Dear @katy,
Try just this and let me know! If it doesn't work - export the form and send it to me at support@plumsail.com

fd.spRendered(() => {
    var lookup = fd.field('Currency');

    function updateFields() {
        fd.field('Rate').value = lookup.value.Rate;
    }

    lookup.$on('change', updateFields);
});

@Nikita_Kurguzov - I sent you the form with the updated code (didn't work) :pleading_face: