Print this page

Using State and Country Picklists in Web-to-lead form

Knowledge Article Number 000213272
Description Sometimes a lead submitted by customer via Web to Lead form might not get saved as a Lead, but the system admin receives an email with the following error message:  

Error:  Salesforce could not create this lead because of the reason listed below. For more information about this error or help with Web-to-Case-Lead, please contact Customer Support.

Reason: A country must be specified before specifying a state value for field
Resolution

This error message indicates that 'State and Country as a Picklist' is enabled in your Org.

If the Web to Lead form contains standard 'State' and 'Country' fields and the submitter fills the value in 'State' but does not mention the 'Country', then this error message will be sent to the system admin. However, if 'Country' is selected and 'State' is not, then the Lead would get submitted successfully without any error. 


This error can be avoided by:

  • Creating custom 'State' and 'Country' fields on Lead and use them on the Web-to-Lead form.
  • Make the standard 'Country' field is required via HTML Coding (and not Salesforce Validation Rules). Please note that, HTML coding is not supported as part of Salesforce support and should be done by the webmaster or the web developer

Also, when 'State and Country as a pick list' is enabled in an Org, the standard 'Country' field acts as a Controlling Pick List and 'State' field acts as Dependent Pick List. However, when the same fields are used on W2L form, this dependency is not carried forward. This is the reason that the State field would show the value of all States available in the Org, irrespective of the 'Country' selected above. 

If a customer tends to select incorrect State for any Country, that lead would not get submitted successfully. The system admin would receive a similar email with the details of the Lead

This error can be avoided by: 

  • Contact your Company's webmaster to bring this dependency in the form using Javascript or any other equivalent/advanced web technology
Note: Existing TEXT HTML Code can still be used on the web to lead form and Leads will still come through without updating the API code to a picklist (Country) Field as long as the external customer who uses the web to lead form use the same country text format.




promote demote