Export function not collecting field value of auto fill code

I’ve been following a vorbly code guide to try and get my auto fill working on a form but have run into some issues and can’t seem to figure it out. I’ve included the comparison for code that works and doesn’t work. The code that doesn’t work is what I really need help figuring out.

This code works :
Shows:


Code:


$w.onReady (function () {
 $w("#input1").value = "Test"
})

export function Submit_click(event, $w) {
        $w('#dataset1').setFieldValue('fname', $w('#input1').value);
}

Database Result:

This code doesn’t work and I can’t figure out why. I’ve been trying to fetch information from another database field to auto-fill a new field in a different database, however it isn’t collecting the input data when I click submit.
Shows:


Code:


$w.onReady (function () {
$w('#dataset2').onReady ( () => {
 $w("#input1").value = $w("#dataset2").getCurrentItem().fname;
      })
})

export function Submit_click(event, $w) {
        $w('#dataset1').setFieldValue('fname', $w('#input1').value);
}

Database Result:

Any help to make it work would be greatly appreciated! I have been trying for hours to figure it out, with no luck.

Thanks in advance :slight_smile:

Is the Submit button connected to the Dataset? If so, then the Submit_click() event handler won’t be run.

What you need is to set the Dataset field value at the same time that you set the input field. Make sure you disconnect the Submit from the Submit_click() function. To clean up, you should also delete the Submit_click() function.

$w.onReady(function () {
    $w('#dataset2').onReady(() => {
        $w("#input1").value = $w("#dataset2").getCurrentItem().fname;
        $w('#dataset1').setFieldValue('fname',$w('#input1').value);
    })
})

This worked perfectly. Thank you so much. I was wondering if you happened to know how to make it that the input1 field doesn’t clear after submission? At the moment it clears after clicking submit.