How to generate serial numbers and store the same in database?

You have just to implement the YEAR into this code, good luck :wink:

var COUNTER = 0

$w.onReady(async function () {
    $w('#myButton').onClick(()=>{
        console.log(generateSerial())
    }) 
});


function generateSerial(){
   const prefix = "PP000"
   let currentCount = (Number(COUNTER++)).toString()
   let mySerial = prefix.substr(0, prefix.length-currentCount.length) + currentCount
   return mySerial
}

You can test the CODE in the CONSOLE. (press F-12 in google-chrome and go to CONSOLE), or do the same in the PreviewMode of your Wix-Editor.