-
Re: Form Prefill Functionality is not working in embed form
Luis Florez Sep 25, 2017 6:34 AM (in response to Nishant Bansal)Just to clarify. Are you using the embed code in a Marketo LP or in a Web Page? You don't need an embed code to display a Marketo form in a Marketo LP, just add a form: Landing Page with a Form - Marketo Docs - Product Docs
Then you select the option to prefill the form.
-
Re: Form Prefill Functionality is not working in embed form
Nishant Bansal Sep 25, 2017 6:42 AM (in response to Luis Florez)I am using the embed code in marketo LP because I am working on some functionality which requires 2 same form with a different layout in desktop and mobile view which is not possible in adding the form functionality.
-
Re: Form Prefill Functionality is not working in embed form
Josh Hill Sep 25, 2017 7:04 AM (in response to Nishant Bansal)Please send us a link or clearer explanation.
- Marketo hosted Landing Page must use the native Form
- Embed code is for external sites. This code does not support all functions like prefill.
- Custom Form - you can write code to do special things, but that's up to you.
- CSS Mods - if you are having trouble with responsive, then you need CSS and other mods. You shouldn't need to re-code the entire Form.
-
-
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Sep 25, 2017 8:06 AM (in response to Nishant Bansal)1 of 1 people found this helpfulI have used the embed code of the form in the marketo LP and to prefill the form I am using rest API's of the marketo but I am getting the error " No 'Access-Control-Allow-Origin' header is present on the requested resource.
Never, ever, ever even think about exposing the REST API directly from a webpage. The security and reliability consequences are absurd. Honestly, you should shut down your web presence before considering this.
In your case, there's no need to consider this. If it's a Marketo LP using the embed code instead of a named Form element (not advisable, but you can do it if you insist) then you can for the most part fill the form using tokens:
MktoForms2.whenReady(function(form){ form.setValues({ LastName : "{{Lead.Last Name}}" }); });
Also be aware that multiple Marketo forms with the same ID on the same page have subtle problems (yes, even if one of them is set to display: none;). You can check some of my posts here for pointers.
-
Re: Form Prefill Functionality is not working in embed form
Nishant Bansal Sep 25, 2017 10:21 AM (in response to Sanford Whiteman)Thanks, Sanford.
Could you please help me to assign the checkbox values also.
-
Re: Form Prefill Functionality is not working in embed form
Ryan Coyle Mar 28, 2018 10:22 PM (in response to Sanford Whiteman)Sanford, Do you have a suggestion on where to use form.setValues() within the 2-step-form script you created (which is working great btw)? I really only need to pre-populate the first form if that would make a difference.
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Mar 28, 2018 10:24 PM (in response to Ryan Coyle)Which one is that? Can you open a new thread and point to your running code?
-
Re: Form Prefill Functionality is not working in embed form
Ryan Coyle Mar 28, 2018 10:47 PM (in response to Ryan Coyle)Working for me so far here,
/* --- NO NEED TO TOUCH ANYTHING BELOW THIS LINE */
// utility fns
var injectMktoForm = function(parentEl, insertBeforeEl, instanceHost, munchkinId, formid, onReady) {
var formEl = document.createElement('FORM');
formEl.id = 'mktoForm_' + formid;
try {
parentEl.insertBefore(formEl, insertBeforeEl)
} catch (e) {
parentEl.appendChild(formEl)
}
MktoForms2.loadForm.apply(MktoForms2, Array.prototype.slice.apply(arguments, [2]));
}
MktoForms2.whenReady(function(form){
form.setValues({
LastName : "{{Lead.Last Name}}",
FirstName : "{{Lead.First Name}}",
Company: "{{Company.Company Name}}",
Email: "{{Lead.Email Address}}",
Phone: "{{Lead.Phone Number}}"
});
});
var ejectElement = function(formEl) {
formEl.parentNode.removeChild(formEl);
}
var arrayPushGet = function(ary, pushable) {
return ary[ary.push(pushable) - 1];
}
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Mar 28, 2018 11:06 PM (in response to Ryan Coyle)1 of 1 people found this helpfulOK, so... what's the question?
-
Re: Form Prefill Functionality is not working in embed form
Ryan Coyle Mar 28, 2018 11:39 PM (in response to Sanford Whiteman)I asked, then I figured it out. I sure do appreciate the quick response
-
-
Re: Form Prefill Functionality is not working in embed form
Mark Brailsford Jun 23, 2018 9:25 AM (in response to Ryan Coyle)Ryan,
This looks like what I need. A couple of questions:
- Is this script a replacement for the provided embed code?
- I would replace instanceHost, munchkinId, formid with the values from the embed code?
- I would just need to replace the field token pairs?
-
-
-
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Sep 25, 2017 11:14 AM (in response to Nishant Bansal)You mean coercing "1" and "" to true and false?
-
Re: Form Prefill Functionality is not working in embed form
Nishant Bansal Sep 25, 2017 11:26 AM (in response to Sanford Whiteman)yes.
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Sep 25, 2017 1:00 PM (in response to Nishant Bansal){
myBooleanField: !!+"{{Lead.Boolean Field}}"
}
-
Re: Form Prefill Functionality is not working in embed form
Nishant Bansal Sep 28, 2017 8:44 AM (in response to Sanford Whiteman)Hi All
I am prefilling around 40 fields with the above method and out of 2 fields are not prefilling. I am using the correct API Name and 1 of them is Company name and 1 is the custom field. Could you please help me in this case.
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Sep 28, 2017 11:49 AM (in response to Nishant Bansal)Need more info. What distinguishes the fields that aren't working? What's the exact output into the JS? Are there syntax errors?
-
Re: Form Prefill Functionality is not working in embed form
Nishant Bansal Sep 28, 2017 12:04 PM (in response to Sanford Whiteman)There is no error in the script. There is no difference in all fields. I am using the same method as Company: "{{Lead.Company Name}}",
but for the company field, it's not working.
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Sep 28, 2017 12:17 PM (in response to Nishant Bansal)It's
{{Company.Company Name}}
-
-
-
-
-
-
-
Re: Form Prefill Functionality is not working in embed form
Johanna Brütsch Sep 28, 2017 10:55 PM (in response to Nishant Bansal)I would apreciate if form-prefill would work in external embedded forms.
Or is there another solution to use the prefill function in external pages?
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Sep 28, 2017 11:20 PM (in response to Johanna Brütsch)There's a method I've used w/my clients for the last couple of years and I'm getting tired of teasing it -- before EOY I'm going to open the source.
-
Re: Form Prefill Functionality is not working in embed form
Johanna Brütsch Sep 28, 2017 11:33 PM (in response to Sanford Whiteman)Hi Sandford, I would be happy if you would share your code here :-) Best Johanna
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Sep 28, 2017 11:58 PM (in response to Johanna Brütsch)It'll be on my blog, but it will be shared.
-
Re: Form Prefill Functionality is not working in embed form
Scott McKeighen Nov 17, 2017 6:59 AM (in response to Sanford Whiteman)Have you released this from the lab yet? Asking "for a friend"
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Nov 17, 2017 10:23 AM (in response to Scott McKeighen)Couple of commercial proposals are still open w/clients... wouldn't be right to open-source it just yet.
-
-
-
-
-
-
Re: Form Prefill Functionality is not working in embed form
bb04dc3bffcc1af2e627a1044010513b66cd89d7 Nov 3, 2017 11:11 AM (in response to Nishant Bansal)Checkout this script: MarTech/Form-Prefill
It prefills embedded Marketo forms using AJAX request to a native Marketo landing page, so you don't need to code anything or use the REST API to query the lead's data.
I'd love to hear your feedback!
-
Re: Form Prefill Functionality is not working in embed form
Sanford Whiteman Nov 3, 2017 11:35 AM (in response to bb04dc3bffcc1af2e627a1044010513b66cd89d7)Marketo changed their CORS policy?
-