Number is inserted to collection as text

Some observations:

This section of code (lines 14 - 17)

const lastItemInCollection = results.items[0];
let orderNumber = `${Number(lastItemInCollection._ID) + 1}`
$w('#orderNumber').text = orderNumber;

Should probably be something like this:

const lastItemInCollection = results.items[0];
let orderNumber = lastItemInCollection._ID + 1; // the _ID field is a number
$w('#orderNumber').text = orderNumber + ''; // make text for the text field

In this line:

console.log($w('#orderNumber').text+' typeof: ' + $w('#orderNumber').type);

$w(‘#orderNumber’).type returns the type of the element, which is $w.Text because the element is a text element.

In confirButton_click(), line 53:

"_ID": Number.parseInt($w('#orderNumber').text, 10), 

Should be :

"_ID": Number($w('#orderNumber').text),

Is the database collection field _ID a number field?