Guys I have a problem. Im using SetFieldValue in my code two months ago, but today sometimes it works and some times doesnt. This is the code
export function crear_click(event) {
$w( “#dataset1” ).setFieldValue( “atendido” , “PENDIENTE” );
$w( “#dataset1” ).save()
}
Any ideas?
This could be interessting for you…
https://www.wix.com/velo/forum/community-discussion/visual-learner-coding-a-repeater
Take a look onto the offered “interactive-example”!
Thanks! Still not working. It very strange! Sometimes it works, sometimes doesnt
Somebody help!
I don’t know if it works but maybe add async to your function (export async functio )
and await before the setfield($w(“dataset1”).setField…
It might be becouse when its setting it as a field its already saving.
Kind regards,
Kristof.
All you need you will find in the post-link i gave you.
Your problem is, that you do NOT use —> onBeforeSave, like shown in the example-code in the given post.
$w.onReady(function () {
$w('#dataset1').onReady(()=>{
var day, month, date, year, sports
$w('#btnSubmit').onClick(()=>{$w('#dataset1').save()})
$w('#dropdown1').onChange(()=>{sports = $w('#dropdown1').value})
$w('#timePicker1').onChange(()=>{console.log("GO2")
$w('#input4').enable()
$w('#input4').value = $w('#timePicker1').value.substring(0, 5)
})
$w('#datePicker1').onChange(()=>{console.log("GO1")
//Get day .....-----------------------------------------------------------------------------------------------------
if($w('#datePicker1').value.getDay()===1) {day = "Monday"; console.log(day); $w('#input1').value = day;}
if($w('#datePicker1').value.getDay()===2) {day = "Tuesday"; console.log(day); $w('#input1').value = day;}
if($w('#datePicker1').value.getDay()===3) {day = "Wensday"; console.log(day); $w('#input1').value = day;}
if($w('#datePicker1').value.getDay()===4) {day = "Thursday"; console.log(day); $w('#input1').value = day;}
if($w('#datePicker1').value.getDay()===5) {day = "Friday"; console.log(day); $w('#input1').value = day;}
if($w('#datePicker1').value.getDay()===6) {day = "Saturday"; console.log(day); $w('#input1').value = day;}
if($w('#datePicker1').value.getDay()===7) {day = "Sunday"; console.log(day); $w('#input1').value = day;}
date = $w('#datePicker1').value.getDate(); $w('#input2').value = date
year = $w('#datePicker1').value.getFullYear(); $w('#input5').value = year
$w('#input3').value = $w('#datePicker1').value.getDate().toLocaleString()
$w('#input6').value = $w('#datePicker1').value.toDateString()
//Get month ....----------------------------------------------------------------------------------------------------
if($w('#datePicker1').value.getMonth()===0) {month = "January"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===1) {month = "February"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===2) {month = "March"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===3) {month = "April"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===4) {month = "May"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===5) {month = "Juni"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===6) {month = "July"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===7) {month = "August"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===8) {month = "September"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===9) {month = "October"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===10) {month = "November"; console.log(month); $w('#input2').value = month;}
if($w('#datePicker1').value.getMonth()===11) {month = "December"; console.log(month); $w('#input2').value = month;}
$w('#input1').enable()
$w('#input2').enable()
$w('#input3').enable()
$w('#input5').enable()
$w('#input6').enable()
$w('#dataset1').onBeforeSave(()=>{
$w("#dataset1").setFieldValues({
"title": "",
"day": day,
"date": date,
"month": month,
"year": year,
"sports": sports
});
});
});
});
});
This is exactly the part i wanted to show you by giving you the link…
$w('#dataset1').onBeforeSave(()=>{
$w("#dataset1").setFieldValues({
"title": "",
"day": day,
"date": date,
"month": month,
"year": year,
"sports": sports
});
});
This code-part you probably will miss in your own code.
And also think about, to use…
$w.onReady(function () {
$w('#dataset1').onReady(()=>{
})
})
Like shown in this code-example.
To see this code in action, click here…
https://www.media-junkie.com/datepicker
@volkaertskristof
Not sure if Async-await would work too, but could also be a possible solution.
@russian-dima Thanks again! still not working 
TRY ONE:
export function createBUTTON_click(event) {
$w( "#dbWrite" ).onBeforeSave( () => {
$w( "#dbWrite" ).setFieldValue( "aprobacion" , "PENDIENTE" )
$w( "#dbWrite" ).setFieldValue( "atendido" , "PENDIENTE" )
$w( "#dbWrite" ).setFieldValue( "estado" , "PENDIENTE" )
} );
}
TRY TWO:
export function createBUTTON_click(event) {
$w( "#dbWrite" ).onBeforeSave( () => {
$w( "#dbWrite" ).setFieldValue( "aprobacion" , "PENDIENTE" )
$w( "#dbWrite" ).setFieldValue( "atendido" , "PENDIENTE" )
$w( "#dbWrite" ).setFieldValue( "estado" , "PENDIENTE" )
$w( “#dbWrite” ).save;
} );
}
Also I forgot to tell you that createBUTTON, is connected to the dataset:

THANKS AGAIN GUYS
@volkaertskristof Can you give me a quick example?
What is it you are trying to accomplish?
It seems as if you have the code correct. See the setFieldValue() API .
The setFieldValue() function does not return a Promise, therefore it does not need an await . Also, you don’t need onBeforeSave() - not to mention that it should not be set in an event handler - createBUTTON_click().
Also, if you have multiple fields to set, you can use the setFieldValues() API . which is used to set the values of multiple fields.
Can you provide more information regarding your issue? Is there any other relevant code that you can share.
- Async-Await not needed → ok, checked
- should not be set in an event-handler —> ok, checked
- but the “onBeforeSave” - command not needed —> hmmm, i am sure i have seen this so often here in posts, where is was used.
However, the shown code is doing his job anyway 
If the button is connected to the dataset then you just have to configure it the right way.
You won’t have to use code to save since the button does the job for you.
in the settings of the connected button you should select on click → send.
But if you want to do it the way you are doing you should disconnect the button and then use the code for the onClick() event.
Well, all I said was onBeforeSave() wasn’t needed - not that it won’t work.
Thanks for taking the time to help me! Still doesnt work. This is the change I made:
export function createBUTTON_click(event) {
$w.onReady( () => {
$w( “#dbWrite” ).onReady( () => {
$w( “#dbWrite” ).setFieldValues( {
“aprobacion” : “PENDIENTE” ,
“atendido” : “PENDIENTE”
} );
$w( “#dbWrite” ).save();
} );
} );
I dont know if because the button is connected to the dataset and performing the save action, there is a conflict. But remember!.. I´ve been using these code 6 months from now and always worked! three days ago stop working
Other fact: I have 3 different sites and all of them have the same code. They used to work, until now. The SetFieldValue its not working on them either
LAST FACT!: I just created a blank site to test the code. Definetly SetFieldValue doesnt work. If you guys wanna give it i try. Create your own blank site and try it. You´ll see there is something wrong with Velo
Thanks for taking the time to help me! Still doesnt work. This is the change I made:
export function createBUTTON_click(event) { $w.onReady( () => { $w( " #dbWrite " ).onReady( () => { $w( " #dbWrite " ).setFieldValues( { “aprobacion” : “PENDIENTE” , “atendido” : “PENDIENTE” } ); $w( " #dbWrite " ).save(); } ); } );
I dont know if because the button is connected to the dataset and performing the save action, there is a conflict. But remember!.. I´ve been using these code 6 months from now and always worked! three days ago stop working
Other fact: I have 3 different sites and all of them have the same code. They used to work, until now. The SetFieldValue its not working on them either
LAST FACT!: I just created a blank site to test the code. Definetly SetFieldValue doesnt work. If you guys wanna give it i try. Create your own blank site and try it. You´ll see there is something wrong with Velo
@danieltalero78
Darn i didn’t see this in your earlyer post.
You have $w.onready(() =>{
})
Should never be in a onClick event always just on the page.
so:
exportfunction createBUTTON_click(event) {$w.onReady( () => { $w("#dbWrite").onReady( () => { $w("#dbWrite").setFieldValues( {"aprobacion": "PENDIENTE","atendido": "PENDIENTE" } ); $w("#dbWrite").save(); } );} );
should be
$w.onReady( () => {
// here should only be code that needs to be executed when the page is loaded.
}
exportfunction createBUTTON_click(event) {
$w("#dbWrite").onReady( () => {
$w("#dbWrite").{
"aprobacion": "PENDIENTE","atendido": "PENDIENTE"
});
$w("#dbWrite").save();
});
@volkaertskristof Thanks again my friend. Can you help me, creating a blank site and try the code? I did it and it doesnt work either
@danieltalero78
Perhaps you try this one…
$w.onReady(function () {
$w('#dataset1').onReady(()=>{
$w('#createBUTTON').onClick(()=>{$w('#dataset1').save()})
$w('#dataset1').onBeforeSave(()=>{
$w("#dataset1").setFieldValues({
"title": "myTitle",
"aprobacion": "PENDIENTE",
"atendido": "PENDIENTE",
"estado": "PENDIENTE",
});
});
});
});
Disconnect your button from dataset.