Data from input element not being inserted into collection

One of the inputs in my custom form is a “ticket number” that is created with code. This ticket number is connected via dataset to my collection. On submission of the form, all my collection files are updated from the form except for the ticket number. Would appreciate any advice as to why it’s not being inserted into my collection?

import {sendEmail, sendEmailWithRecipient} from 'backend/sendEmail';
import wixData from 'wix-data';

$w.onReady(function () {
  $w("#dataset1").onAfterSave(sendFormData);
});

export function gcfCompany_change(event) {generateID() }

 function generateID () {
 var randomString = function(length) {
 var text = "";
 var possible = "0123456789";
 for(var i=0; i < length; i++) {
          text += possible.charAt(Math.floor(Math.random() * possible.length));
        }
 return text;
    }
 let ID = 'GCF' + randomString(4);
    $w("#ticket").value = ID;
    console.log(ID);
}

function sendFormData() {
 const subject = `Form number ${$w("#ticket").value} submitted by ${$w("#gcfCompany").value}`;
 const body = `Contact form number ${$w("#ticket").value} was submitted by ${$w("#gcfFirstname").value} 
    \rCompany Name: ${$w("#gcfCompany").value}
    \rFirst Name: ${$w("#gcfFirstname").value}
    \rLast Name: ${$w("#gcfLastname").value}
    \rEmail Address: ${$w("#gcfEmail").value}
    \rContact Number: ${$w("#gcfTelephone").value}
    \rEnquiry Details: ${$w("#gcfEnquiry").value}
    \rCommunication OptIn: ${$w("#gcfOptin").value}
    \rCommunication OptOut: ${$w("#gcfNo").value}`;
 const recipient = $w("#gcfEmail").value;
 
  sendEmailWithRecipient(subject, body, recipient)
    .then(response => console.log(response)); 
 
  sendEmail(subject, body)
    .then(response => console.log(response));
}

All your other fields are STRINGS ?
And the only one which is not working is a NUMBER?

My other fields are strings. If I console.log(typeof ‘ticket number’) the result is also string.