Glitch ! dataset setFieldValue

Seems to be a problem when setting dataset field values. Was working before now it is not.

It keeps overwriting previous database entries with new entries in the live mode

$w(‘#button1’).onClick( function () {
$w(“#dataset1”).onReady(() => {

                                $w('#dataset1').setFieldValue('firstName', $w('#firstNameInput').value); 
                                $w('#dataset1').setFieldValue('lastName', $w('#lastNameInput').value);

Hi Mike

Do you have another dataset onReady function registered in your page onReady function perhaps?

Its best to only have one If so. If you post the page code and/or the published url it will be easier to help diagnose.


@steve thanks, I only have the one onReady function. I have worked on the code a bit to the point where I am getting new entries in the database however the new entries contain no data, they are blank. The console.log for each field value contain data they are not blank , my full page code below:

import wixUsers from ‘wix-users’;

$w.onReady( function () {

$w('#buttton1').onClick( **function**  () { 
    $w("#dataset1").onReady(() => { 

if (wixUsers.currentUser.loggedIn) {

let user = wixUsers.currentUser;

                .then((email) => { 

let userEmail = email;

let userId =;

let fisrtName = “Joe”;
let lastName = “Blogs”;

                    $w('#dataset1').setFieldValue('firstName', (fisrtName)); 
                    $w('#dataset1').setFieldValue('lastName', (lastName)); 

                    $w('#dataset1').setFieldValue('email', (userEmail)); 
                    $w('#dataset1').setFieldValue('userId', (userId)); 





Hi Mike:

So now that I can see all of your code here is a problem.

You are not saving the new values into the dataset. All you are doing is changing the values of the fetched record that the dataset maintains. In order to make the new changes permanent you need to save the dataset .

The documentation here states:

Setting the value of a field in a dataset item does not immediately set that value in the collection that the dataset is connected to. You still need to call the dataset save() function or any other function that performs a save to have the new value reflecting in the collection.
So I would add the following line to your code

$w('#dataset1').setFieldValue('userId', (userId));

Hope this helps.


@Steve That solved it, thanks appreciate the help

Excellent news! When you get a chance can you mark the answer as Top Comment ?