I am designing a simple Boolean input into a database. I created a box, added the onClick event, created a database, created the field in the database to run the test, and verified that all the applicable item had the correct name. I used the following code to make the Boolean field “true”:
$w ( ‘#dataset1’ ). setFieldValue ( “test1” , true );
After running the code, I got the error message: DatasetError: There is no current item
What is the problem?
Long ago there was a thread, very similar to your problem…
https://www.wix.com/corvid/forum/community-discussion/keep-switch-on-until-switched-back-by-member/p-1/dl-5ef0a5425de91a0017455aed-5ef079bbf0d26200170de110-1?commentId=5ef079bbf0d26200170de110&origin=notification&postId=5ef01016e0dae4004ab6c2e1&replyId=5ef0a5425de91a0017455aed
But i would recommend you another solution, by using the “save”-API-function for example…
import wixData from 'wix-data';
let toSave = {"test1": true};
wixData.save("contactForm", toSave)
.then( (results) => {
let items = results.items;
console.log(items)
} )
.catch( (err) => {
let errorMsg = err;
} );
The adventage of this solution is, that you do not need any datasets
You could perhaps also use “insert”-API-function…
Or the “update”-API-function…