What are you using this for, may I ask?
In any case, you can generate a UUID. Here the Marketo field being populated is called FormSubmissionID. You would swap that with the SOAP name of the field in your instance:
(function(){
/**
* @preserve contains SO @broofa's UUID polyfill (https://stackoverflow.com/questions/105034/)
* @author https://stackoverflow.com/users/109538/broofa
* @license CC-BY-SA
*
*/
function uuidv4() {
var crypto = window.crypto || window.msCrypto;
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
MktoForms2.whenReady(function(mktoForm){
mktoForm.addHiddenFields({
FormSubmissionID : uuidv4()
});
});
})();
Also, this is adding the UUID when the form is displayed, rather than just before it's submitted. Is there a specific reason you want it added just before submission (since it's globally unique anyway)?