Clear a reference field - SOLVED

Hello, I’m trying to clear a reference field from a form / code to it’s original blank value

I’ve tried with 3 different trials:

$w( '#referenceinputfield ).value = null
$w( '#referenceinputfield ).value = “”
$w( '#referenceinputfield ).value = ‘’

where I use this value in some code later in the page with a button

$w( ‘#DBxxxx’ ).setFieldValue( ‘regione’ , $w( '#referenceinputfield ).value);

but the result is always

What I need is to bring the field to defalt value like

Thanks a lot for your help!

Try undefined or simply not setting it at all if value if empty (so not doing the setFieldValue.

Hi Giri,
thanks for your help.
The problem is that the value can be full or empty, since the record in in the modify process and not only insert.
So it can happen that I need to clear it from the starting point of having some data in it.
Anyway I’ll try “undefined” and let you know the result.
Thanks

Hi Giri,
many thanks, I confirm that putting “undefined” (if the field is not previously empty) or not putting anything (if the field is already empty) the problems is solved.

Here some code to help
To recap: if you need to clear a refernce field already filled with data, write code as below.

$w( ’ # your-dataset ’ ).setFieldValue( ‘your-field’ , undefined);

in my case this code in under a “onclick()” action for a button connected to a dataset with “send” action