lizyjeywin lizyjeywin - 9 months ago 59
jQuery Question

prefill Marketo fields on Submit

On submit of Marketo form it does some processing and returns back to the same page.

My requirement

I would like to have all the Marketo fields populated with the just entered data (data entered before clicking Submit button)for all the Marketo fields.

What I have tried

I have used the below code, that's given in

MktoForms2.whenReady( function(form) {
//set the first result as local variable
var mktoLeadFields = mktoLead.result[0];
//map your results from REST call to the corresponding field name on the form
var prefillFields = {
"Email" :,
"FirstName" : mktoLeadFields.firstName,
"LastName" : mktoLeadFields.lastName,
"Company" :
//pass our prefillFields objects into the form.vals method to fill our fields

But when the form submits and loads\returns back its not populated with previos entered data

Answer Source

I checked the declared variable - here its

var mktoLeadFields

(given in Q) and made a logic that assigned the pre-enetered value to that var and then when set the form values with


it worked.