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
CRYCRY 

Issue with web-to-lead form

Hi, 

I am using Salesforce generated web-to lead form HTML code in the company's webpage. 

Since I intend to validate my page and not use Salesforce features, I am required to use name/id attribute of an input tag to check the fields for empty etc..

 

I am successful in doing so with the standard fields since the name is a valid CDATA type. I am getting syntax errors for the custom fields if I try to do something like 00N80000003jEzY.focus(), since the name 00N80000003jEzY is considered invalid.
 
I this a bug in salesforce or am I doing something wrong? Please help.
 
Standard fields:

<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>

<label for="state">State/Province</label><input  id="state" maxlength="20" name="state" size="20" type="text" /><br>

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

Custom fields:

Survey_QA:<textarea  id="00N80000003jEzY" name="00N80000003jEzY" type="text" wrap="soft"></textarea><br>

SI Campaign ID:<input  id="00N80000003jEz9" maxlength="100" name="00N80000003jEz9" size="20" type="text" /><br>

 

 

Thanks

jkucerajkucera

Here's some hidden field best practices.

 

Change the name to start with a text value that matches the SFDC field name and you should be fine:

 

SI Campaign ID:<input id="Campaign_Id" name="Campaign_Id" value = "00N80000003jEz9"/>

 

Include type=hidden to hide the field value.

CRYCRY

Hi John,

 

Thanks for the reply. Unfortunately the solution you provided do not seem to work.

 

I created a simple html file to capture just the campaign id in the format you provided. But in vain.

 

If you have a working solution plese send it across. If its a bug in the system please provide me with a workaround solution to this problem.

 

Thanks 

jkucerajkucera

Please post your HTML form that's not working.  A typical form might look like:

 

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST"> <input type=hidden name="oid" value="00D30000000XMMI"> <input type=hidden name="retURL" value="http://www.returnurl.com"> <label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br> <label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br> <label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br> <label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br> <input type="hidden" id="Campaign_ID" name="Campaign_ID" value="70130000000AZ09"/> <input type="hidden" id="member_status" name="member_status" value="" /><br> <input type="submit" name="submit"> </form>

 

 

 

 

 

jkucerajkucera

One thing I noticed-the campaign Id you had looked to be a custom object ID, not a campaign ID.

 

Campaign ID's start with 70 such as:

 

70130000000AZ09

 
The value of the campaign_id field should be the ID of that campaign starting with 70.  You can include a different status using the status hidden field as well if you don't want the default used for that campaign.

CRYCRY

Hi,

 

I want to use three custom fields SI campaign Id, Practise Speciality and Survey_QA.

 

The code for this is :

 

Survey_QA:<textarea  id="00N80000003jEzY" name="00N80000003jEzY" type="text" wrap="soft"></textarea><br>


SI Campaign ID:<input  id="00N80000003jEz9" maxlength="100" name="00N80000003jEz9" size="20" type="text" /><br>


Practice Specialty:<select  id="00N80000003iUOy" name="00N80000003iUOy" title="Practice Specialty"><option ........

 

 

Question is: Why is the id and name for each of these fields starting with "00..." whereas for the standard fields like city for example, the name and id is valid.

 

<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br> 

 

I am having problems with custom fields in general since I am not able to use the name and id attributes for validation purposes as HTML/java script does not like " 00N80000003iUOy" names

 

Please let me know if I can contact you on phone, this is something I need to fix by today. 

 

Thanks 

jkucerajkucera

I think the problem is that you're trying to use the ID for the field instead of the ID for the record that you want to use as a value for that field.

 

For Id & Name, use the field name such as:

  • Survey_QA__c
  • Campaign_ID
  • Practice_Specialty__c

 

For the value, use the record ID, which for a campaign would look like:

  •  70130000000AZVJ
CRYCRY

Let me ask you this Q: Are you telling me that i need to "suffix" each custom field with "__c" in order to avoid Salesforce from providing me with an ID and name that HTML would come back as invalid?

 

I thought i would check in with you on this before i went in and made changes to the current feilds that i have there.

 

Ex:  

 

Currently, Survey_QA comes back with :

Survey_QA:<textarea  id="00N80000003jEzY" name="00N80000003jEzY" type="text" wrap="soft"></textarea><br>

 

Once i make your suggested change, can you confirm if Survey_QA__c would look like below ? 

Survey_QA:<textarea  id="Survey_QA__c " name="Survey_QA__c " type="text" wrap="soft"></textarea><br>

  

 

jkucerajkucera

Sorry CRY - I gave you bad info as I mixed up Visualforce syntax with Web to Lead syntax as I've been spending most of my time creating Visualforce & apex lately. 

 

The API name I recommended for custom fields will NOT work: Survey_QA__c

 

Your Id syntax for custom fields should work: id="00N80000003jEzY"

 

 The only exception is for Campaigns, where Campaign_ID should be used for ID & Name, and the value should be that of the campaign you wish to add the lead to.

 

If your custom fields not populating correctly, you should submit a case with support so they can dive deeper into your specific implementation of the form to debug problems.

 

Sorry for the confusion on this.

CRYCRY

Well, okay !! Who is support?,

 

I was asked to place a case in here by Andrew Carballo from Support (email id: acarballo@salesforce.com) who raised a case number (no: 02824225)

 

BTW all I was trying to say is: Id syntax for custom fields: name="00N80000003jEzY" id="00N80000003jEzY"  does not work because HTML does not understand name/id attribute in this format (name/id attribute cannot start with a number).

 

Now who do I contact for web-to-lead issues? 

 

Thanks

jkucerajkucera

Sorry for the frustration.  Sounds like you're trying to use a method like this one to validate your form. 

 

Instead of referencing form elements by FormName.<name>.dosomething(), you should be able to use different syntax such as this if from the same script block as your form:

 

http://www.javascript-coder.com/javascript-form/javascript-get-form.htm

http://www.w3schools.com/HTMLDOM/met_text_focus.asp

 

formname.elements["00N80000003jEzY"].

 

or this if in another script tag:

 

var myField=document.getElementById("00N80000003jEzY");

myField.focus();

 

or this:

 

document.getElementById("00N80000003jEzY").focus();

jkucerajkucera

I talked to another PM about this too - some browsers are now strictly disallowing ID's that start with a number instead of a character.

 

A workaround is to change the ID, but leave the name as is:

 

Survey QA:<textarea  id="SurveyQA" name="00N80000003jEzY" type="text" wrap="soft"></textarea><br>

 

You can then reference the field directly using:

 

form.SurveyQA.focus(); 

 

instead of potential errors as browsers change.  

 

I'm adding a feature task to my product backlog to change how Web to Lead generates the form details for custom fields given this change in browser interpretation of Id's that begin with a number.

 

CRYCRY

Thanks for providing me this solution. Although I was aware of this method, i was trying to access the value of the field directly using the name.

 

I am sorry if I sounded frustrated. I was looking for a solution to the problem as early as possible.

 

Thanks again !! 

jkucerajkucera

Glad we finallly got to a solution and I'm glad you posted as it alerted me to the browser parsing changes.

 

I'd be frustrated in your position too given I gave you a wrong answer, then suggested a route you already took before getting to the core.  Thanks for your patience!

CRYCRY
Thanks again John
TL2000TL2000

John-

 

I am trying to hide and pass the Lead Record Type but have been unsuccessful with 30 attempts.  I have been able to hide custom fields, but I think this may have to do with Lead Record Type being a standard SF Field.  Any suggestions?

TL2000TL2000

Thanks for the quick reply.  Unfortunately, the links are not working for me.  could you send the links to travis.low@webmarketing123.com?  thanks!

CloudGoferCloudGofer
User-added image

If you are looking for advanced email to lead conversion app which does following

1. Configure data elements for parsing using simple configuration page (instead of coding)
2. Support multiple email templates/formats
3. Set default values to lead fields (e.g. for record type, Lead source, Campaign)
4. Attach lead to a campaign
5. Process attachments
6. Simulate parsing of text to Lead (Built in simulator)
7. Extensive Error/Warning reporting

Then try Email2LeadPro AppExchange package: https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFoGaUAL

More details at: http://www.cloudgofer.com/email2lead/