Autoincrement serial number for wix custom form submission

It is possible.
First add a serialId field to your collection.
Then make an index with this field and set it as Unique index (not regular index).
Once you set it as unique, the system will not let you enter the same number twice, even if 2 users make a submissions at the very same moment.

Now after you added this field, you can do something like this:
In the backend data.js file, add an beforeInsert hook like this.

//backend/data.js
///top line:
import wixData from 'wix-data';
///

export async function CollctionName_beforeInsert(item, context){
let prevSerialId = 'ABC00000';
if(!item.serialId){
const prevItemQuery = await wixData.query('CollctionName').isNotEmpty('serialId').limit(1).descending('serialId').distinct('serialId');
const items = prevItemQuery.items; 
if(items.length){
prevSerialId = items[0];
}
} else {
prevSerialId = item.serailId;
}
const nextNumber = Number(prevSerialId.replace('ABC', '')) + 1;//this one will remove the 'ABC' and process the number itself and will add plus one;
item.serailId = 'ABC' + nextNumber.toString().padStart(5,'0');
try {
return item;
} catch(err) {
  return err.errorCode === 'WDE0123' ? CollctionName_beforeInsert(item, context) : Promise.reject(err)
}
}

Now, please have a look at this sections;

catch(err) {
  return err.errorCode === 'WDE0123' ? CollctionName_beforeInsert(item, context) : Promise.reject(err)
}

This part is for the rare cases where several users have submitted at the very first moment, so one of the serailId got rejected for duplication (error code WDE123), in this case it try running the function again (and again) with with an incrementing number .
I didn’t do anything with other unexpected errors just rejected the submission. You can handle it as you want.

P.S. I wrote the answer right here and not in the editor so there might be typos, erros etc… + I haven’t tried it.