+ Start a Discussion
Jim ProtheJim Prothe 

How to auto-populate a web form?



I'm building a web-to-lead form, and I'd like visitors coming from an email to have the form populated automatically with whatever data I already have on them within salesforce.com.


In other words, if I already know who someone is in my org, I don't want to force them to fill in all their information again.




That would not be something you'd do with Web To Lead.  You'd be better off doing that as a Sites or Customer Portal page.



Here's more details on the code to get you started with a sites page.  You could change the controller to Lead in this case if you wanted to pre-populate the form for new lead creation.


As an alternative to Sites or Customer Portal, you could use URL parameters in the link to your web-to-lead form and Javascript to do the pre-population.

For example, say your web-to-lead form is located at www.mycompany.com/contactus.html

With URL parameters, the link becomes: www.mycompany.com/contactus.html?fn=John&ln=Wayne&e=jwayne@xyz.com

You would then write Javascript to parse the parameters from the URL and map (pre-populate) the corresponding fields on the web-to-lead form.

In the above example, fn would prepopulate First Name, ln = Last Name, e = Email, and so on.

Depending on the number of fields you need pre-populated, the link could get long & ugly! But it most certainly can be done on a standard web-to-lead form.