changing value of marketo form before submit
I have to strip out the personal data from marketo forms submitted. Inside the form.onSubmit I look for names of forms that meet criteria of personal data. If any exist I call the API method form.submittable(false) I make an ajax call to a 3rd party passing the personal data to them and then use a callback to attempt to update the form.vals(newObj) object with "REDACTED" string in place of the personal info and continue submitting the marketo form.
But the form does not submit and though the object newObj has the correct entry for the personal name value pair when I console out the form.vals() the pair has "null" as the value instead of "REDACTED". I also use form.setValues(newObj) and still see the same.
Everything works until the code reaches this block.
// submit the marketo form
const submitMarketo = function () {
console.log('submit this to marketo!!!');
console.log(newObj); // returns the new values with redacted info ie: "personal_phone": "REDACTED"
form.setValues(newObj); // attempts to set the new values with redacted info
console.log(form.vals()); // returns the values with personal info as null ie: "personal_phone": null
console.log(form); // returns the correct form
form.submittable(true).submit(); // appears to do nothing, network panel does not show call to marketo,
// if I comment out the form.setValues(newObj); the submit goes through
}form.setValues({[key]: "REDACTED"});
console.log(form.getValues());