-
Re: Fill Marketo Form using Tokens/URL Parameters
Sanford Whiteman Jan 24, 2019 12:52 PM (in response to Audreon Babb)-
Re: Fill Marketo Form using Tokens/URL Parameters
Audreon Babb Jan 25, 2019 10:45 AM (in response to Sanford Whiteman)Thanks! Should be better now.
-
Re: Fill Marketo Form using Tokens/URL Parameters
Sanford Whiteman Jan 25, 2019 11:18 AM (in response to Audreon Babb)No way is that compiling with the extra @ @ @ in there. That's a syntax error.
Once you fix the syntax error(s) the main problem is that you want
target: "Email"
not
target: "Email Address"
-
Re: Fill Marketo Form using Tokens/URL Parameters
Audreon Babb Jan 25, 2019 3:32 PM (in response to Sanford Whiteman)Thanks, I updated the code to the below and placed it in an html block on the landing page where the form is hosted, but I'm not seeing email address populate. renewemailaddress is a custom field I made in Marketo. Maybe I have that name wrong?
<script> MktoForms2.whenReady(function(form){ // Set your proxy (hidden) field to visible field mappings var proxySources = [ { source : "renewemailaddress", target : "Email", readOnly : false } ]; // --- No need to touch below this line! --- var formEl = form.getFormElem()[0], readyValues = form.getValues(), mktoFieldsObj = {}, arrayFrom = Array.from || Function.prototype.call.bind(Array.prototype.slice); proxySources .filter(function(proxy){ return !!readyValues[proxy.source]; }) .forEach(function(proxy){ var fieldEls; mktoFieldsObj[proxy.target] = readyValues[proxy.source]; if (proxy.readOnly) { fieldEls = formEl.querySelectorAll('[name="' + proxy.target + '"]'); arrayFrom(fieldEls) .forEach(function(el){ el.readOnly = el.disabled = true; }); } }); form.setValues(mktoFieldsObj); }); </script>
-
Re: Fill Marketo Form using Tokens/URL Parameters
Sanford Whiteman Jan 25, 2019 3:43 PM (in response to Audreon Babb)1 of 1 people found this helpfulField names are case-sensitive. Are you sure that's the SOAP/form field name?
-
Re: Fill Marketo Form using Tokens/URL Parameters
Audreon Babb Jan 25, 2019 4:05 PM (in response to Sanford Whiteman)That was definitely it; should have been renewEmailAddress. I appreciate the help!!
-
Re: Fill Marketo Form using Tokens/URL Parameters
Audreon Babb Feb 4, 2019 1:47 PM (in response to Sanford Whiteman)As a follow up, can this be done with multiple fields in the same JS code? Trying to do this for multiple fields but I'm not sure of the correct syntax.
Below is what I've tried.
<script> MktoForms2.whenReady(function(form){ // Set your proxy (hidden) field to visible field mappings var proxySources = [ { source : "renewEmailAddress", target : "Email", readOnly : false } { source : "renewAccountNumber", target : "acc", readOnly : false } ]; // --- No need to touch below this line! --- var formEl = form.getFormElem()[0], readyValues = form.getValues(), mktoFieldsObj = {}, arrayFrom = Array.from || Function.prototype.call.bind(Array.prototype.slice); proxySources .filter(function(proxy){ return !!readyValues[proxy.source]; }) .forEach(function(proxy){ var fieldEls; mktoFieldsObj[proxy.target] = readyValues[proxy.source]; if (proxy.readOnly) { fieldEls = formEl.querySelectorAll('[name="' + proxy.target + '"]'); arrayFrom(fieldEls) .forEach(function(el){ el.readOnly = el.disabled = true; }); } }); form.setValues(mktoFieldsObj); }); </script>
-
Re: Fill Marketo Form using Tokens/URL Parameters
Sanford Whiteman Feb 4, 2019 10:49 PM (in response to Audreon Babb)You absolutely can use an array of objects: in fact, you already are using an array in the first example, it simply happens to have only a single object in it.
You left out a comma between the 2 objects, however.
var proxySources = [ { source : "renewEmailAddress", target : "Email", readOnly : false }, { source : "renewAccountNumber", target : "acc", readOnly : false } ];
-
Re: Fill Marketo Form using Tokens/URL Parameters
Audreon Babb Feb 5, 2019 8:06 AM (in response to Sanford Whiteman)Awesome, thanks again.
-
-
-
-
-
-
-