# insertReference doesn't work, use DataSet.new!

**URL:** <https://forum.wixstudio.com/t/insertreference-doesnt-work-use-dataset-new/8501>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [December 21, 2020, 2:02pm UTC](https://forum.wixstudio.com/t/insertreference-doesnt-work-use-dataset-new/8501 "2020-12-21T14:02:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![osnat\_po](https://avatars.discourse-cdn.com/v4/letter/o/dfb087/32.png) [@osnat\_po](https://forum.wixstudio.com/u/osnat_po)\
**Post date:** [December 21, 2020, 2:02pm UTC](https://forum.wixstudio.com/t/insertreference-doesnt-work-use-dataset-new/8501/1 "2020-12-21T14:02:39Z")

</div>

I saw I’m not the first one that insertReference didn’t insert correct data into collection.  
So finally I succeed doing so with DataSet item:  
$w( “#MyDataSet” ). **new** ()  
.then( ( ) =\> {  
console.log( “New item created” );  
$w( “#MyDataSet” ).setFieldValues( {  
“date” : $w( ‘#dateBuyingNewItem’ ).value,  
“Name” : $w( ‘#inpName’ ).value,  
// This is my reference field, when loaded the drop down component I already loaded the items ID as the Value property of each item  
“dealer” : $w( ‘#dropDownDealer’ ).value  
} );  
$w( “#MyDataSet” ).save();  
} )  
. **catch** ( (err) =\> {  
**let** errMsg = err;  
} );

That’s it!  
The only problem is that the screen is flickering twice, since the data set is refreshing twice: once when DataSet.New command is saving the last item, second when DataSet.Save command is called.
