Saving data problem

Well I’m trying to have a data base that saves form inputs and output results calculated. So I would have the calculated results saved and the input information in the database
To do this I connected the inputs with the fields, as for the output I did this:

import wixData from ‘wix-data’

export function button1_click_1(event) {
$w( “#dataset1” ).onReady( () => {
$w( ‘#dataset1’ ).setFieldValues({
‘Consumo diário de água por habitante (litros/dia.pessoa)’ : WATER,
‘Consumo anual de eletricidade (kWh/ano)’ : TotalE,
‘Consumo anual de gás (kWh/ano)’ : TotalG2,
‘Energia produzida pelos panéis solares (kWh/ano)’ : ENERGIAS ,
‘Energia produzida pelos panéis fotovoltaícos (kWh/ano)’ : EnergiaFoto,
‘Consumo anual de energia (kWh/ano)’ : TotaL,
‘Consumo anual de energia por metro quadrado (kWh/ano.m2)’ : Total,
});
$w( “#dataset1” ).save();

})
}
It saved just as I wanted to for the last two weeks, but now it doesn’t.
No longer saves this results, only the inputs on the form. At first the error was “Cannot read property ‘getId’ of undefined” now it just says “the request cannot be fulfilled”
The results are calculated in another function, and everything is still working except for saving…
I’m really having trouble with this can somebody help me and tell me what the problem might be? Im clueless here :confused:

See setFieldValues() function from Wix Dataset API.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValues

The first part has to be the field key of the field name that you are saving to.

The second part has to be the new value that you are saving into that field.

Examples
Set several fields’ values

$w("#myDataset").setFieldValues( {
  "title":  "New Title",
  "name":   "New Name"
} );

So the above would be something like this in code on a page…

$w("#myDataset").setFieldValues( {
  "title": $w("#titleInput").value,
  "name": $w("#nameInput").value
} );

Also with this line here…

export function button1_click_1(event) { 

This normally happens if you add a onClick event handler function to an element that is already in your code and it will automatically add a _1 at the end of the function name.

As you can’t have two buttons with the same id name of button1, then check your page setup to make sure that this actual button has the right event handler function tied to it.

Thank you for reply but it’s not input I want to save it’s output calculated values, for exemple I have something like:
let x= 0
let y=0
export function button1_click_1(event) {
let a=Number( $w ( “#Input1” ). value) ,
let b=Number( $w ( " #Input2 " ). value) ,
x=a+b
}
export function button1_click_1(event) {
let c=Number( $w ( " #Input1 " ). value) ,
let d=Number( $w ( " #Input2 " ). value) ,
y=c+d
}
import wixData from ‘wix-data’
exportfunction button1_click_1(event) {
$w( " #dataset1 " ).onReady( () => {
$w( ’ #dataset1 ’ ).setFieldValues({

‘Result1’ : x,
‘Result2’ : y,
});
$w( " #dataset1 " ).save();
})
}