Hi, using the below code to register a new player to our leaderboard. This is done using a lightbox with write only permissions to a dataset which is connected to the leaderboard page, repeater etc. For the life of me, i cannot figure out why it creates two duplicate entries every time the submit button is clicked - and one of those entries ‘points’ field is always not converted to an integer. I tried doing this same process with the setfieldvalue function and saving the dataset but had no luck getting this to work so trying it this way instead.
export function button4_click ( event ) {
let eventsAttended = parseInt ( $w ( “#input2” ). value )
let wins = parseInt ( $w ( “#input3” ). value )
let losses = parseInt ( $w ( “#input4” ). value )
let draws = parseInt ( $w ( “#input5” ). value )
**let** totalpoints = ( wins * 2 )+( draws )+( eventsAttended * 3 )- losses
//$w("#dataset1").setFieldValue( "points", totalpoints);
**let** toInsert = {
"name" : $w ( "#input1" ). value ,
"store" : $w ( '#dropdown1' ). value ,
"eventsAttended" : parseInt ( $w ( "#input2" ). value ),
"wins" : parseInt ( $w ( '#input3' ). value ),
"losses" : parseInt ( $w ( '#input4' ). value ),
"draws" : parseInt ( $w ( "#input5" ). value ),
"points" : parseInt ( totalpoints )};
wixData . insert ( “YUGLeaderboard” , toInsert )
. then ( ( results ) => {
let item = results ; //see item below
} )
. catch ( ( err ) => {
let errorMsg = err ;
} );
}