function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
WERD2WERD2 

Passing values to Web to Lead form?

A few years ago I saw a demo where a customer merged the Lead ID into to append to a URL in an email template. The URL pointed the email recipient to a web to lead form which had the Lead ID pre-populated from the merged Lead ID field contained in the URL. By doing this, the customer was able to send out event registrations to existing Leads and have them register for the event (Campaign) via a web to lead form without needing to provide information which they had previously provided.

 

I can setup the email template to include the merge field, however can't work out how to get the lead ID field on my web to lead form to populate. 

 

I thought the URL should look like this, although this just loads the web to lead form without inserting the Lead ID - http://www.<mywebsite>/html?Lead.Id=<lead record id>

 

Any suggestions?

Message Edited by WERD2 on 03-22-2009 04:36 AM
Best Answer chosen by Admin (Salesforce Developers) 
jkucerajkucera

http://blogs.salesforce.com/marketing/2007/03/autoassociating.html

 

Yes that syntax works, though the name should be defined to match the SFDC field name.

All Answers

jkucerajkucera

http://salesforcewebform.com/pillarfinance.html?fn=john&ln=kucera&email=jkucera@salesforce.com&phone=415-555-1234&company=Salesforce&cmid=000000000000

 

Check out the source code for this example.   

 

The key javascript calls that gets the variables from the URL:

function getQueryVariable(variable) {var query = window.location.search.substring(1);var vars = query.split("&");for (var i=0;i<vars.length;i++) {var pair = vars[i].split("=");if (pair[0] == variable) {return pair[1];} }}

 And the call that populates it back into either a hidden or shown field:

document.webtolead.CampaignMemberID__c.value = getQueryVariable("cmid") 

 

This starts to get really interesting w/ Salesforce Sites coming out in June.  You can pass the Campaign Member ID ivia merge field in the email URL and use web forms to update the Campaign Member event fields such as 'meal preference', 'Offer', or 'Hotel'.

 

(Note-custom fields will be released mid July for Campaign Member) 

withoutmewithoutme

Will this work for passing values to hidden fields in the URL? If it does, how do I define my hidden field?

 

<input type="hidden" name="hiddenfieldname" value=""> Is that right? 

jkucerajkucera

http://blogs.salesforce.com/marketing/2007/03/autoassociating.html

 

Yes that syntax works, though the name should be defined to match the SFDC field name.

This was selected as the best answer
TigerPowerTigerPower

Hello,

and thank you very  much for your links and advice. I got my webtolead form working with prepopulated standard sf fields. But how about those custom fields? Have someone worked out with custom fields (with leading zeros) and javascript?

 

Here's what I mean:

 

 

<!--This is working piece of code--> document.webtolead.company.value = getQueryVariable("company") document.webtolead.street.value = getQueryVariable("street") document.webtolead.zip.value = getQueryVariable("zip") document.webtolead.city.value = getQueryVariable("city") <!--These are custom fiels, that do not work with javascript--> document.webtolead.00N20000001tdYP.value = getQueryVariable("co1") document.webtolead.00N20000001tdYG.value = getQueryVariable("co2")

 


 

 

What do think? Should the javascript be written with whole different approach?

 

Best Regards,

TP

 

Message Edited by TigerPower on 06-22-2009 09:46 AM
swimminglyswimmingly

Would love to view the source for a Sites based web form that accepts URL parameters.  Can't seem to find my error!

Frank van Meegen 29Frank van Meegen 29
I am looking for a solution just like the description of this post. Unfortunately  the url to the page in the best answer is not working anymore. Can someone please share the solution to this question with me?