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
Laura GilLaura Gil 

How to set a lead record type when creating a lead via web-to-lead?

Hi all,
I would like to create a web-to-lead which will set the record type accordin to certain criteria.
I found this blog which is doing what I would like to achieve:
 
https://www.simplysfdc.com/2013/06/salesforce-setting-record-type-in-web.html
 
The problem is that this needs the Id of the record type:

<input type=hidden name="recordType" id="recordType" value="01250000000HkoV">
 
that means it needs hardcoding.
 
Does anyone know if there is a way not to use hardcoding for the used input type tag or just if there is a way not to hard code this?
AnkaiahAnkaiah (Salesforce Developers) 
Hi Laura,
By using workflow rule, you can update the lead record type automatically when creation lead from web.
Use the specific criteria as per your business need and update the recordtype of lead.

Example:

If lead is creating from web, then create a worflow rule like
User-added image

If this helps, Please mark this as best answer

Thank you!!