Debugging web to lead forms using salesforce proactively and easily.

Imagine that you are a salesforce admin or developer and your website lead form is integrated with salesforce. All of a sudden, the leads are no longer coming in. You think how on earth am I going to do fix this? The only thing which shows up is the form getting submitted and redirected to the page which you want but when you log back in salesforce, there is no lead created at all.

So what are the best ways to debug web to lead forms and fix issues? This post would help developers and salesforce admins to identify the issues quickly and prevent major problems later.

View the error in debug log right away

As soon as you see an issue with the web to lead form, the first thing you want to do is enable the debug log and see if there is any error. Here are steps which you can do to make this happen.

a. Before you enable debug log, you need to make yourself the lead owner. You have to do this to see the debug log otherwise you will not be able to see any debug logs at all.

b. Go to setup–> logs-> Enable debug logs.

c. You should look for the web to lead logs and see if there is any errors which show up. Based on the error, you need to act on it right away.

2. Watch out for null pointers exceptions on the lead insert triggers.

Now you would see errors like Null pointer exceptions on the error log. Here are things which you can do to fix them.

a. If you have any custom fields on the lead with a default values assigned to the fields, the default values will not be populated on web to lead forms. The default values on leads would only be populated if the lead is manually created inside the salesforce org and will never work when called using an api. Web to lead forms use the api and so thi swill not work. Your lead insert triggers might be expecting a value on the field which will fail now with a null pointer exception. So make sure you put a default value on the triggers to gix this issue once for all.

b. Some times, you might have created required fields on the leads without testing the web to lead forms. Now these required fields or validation rules do work inside the salesforce org but on the web to lead forms, they would throw errors which need to be fixed right away.

3. Proactively handling web to lead form errors.

Since web to lead forms are such a black box where there is not an easy way to fix the issues, one of the thing I would recommend is using a custom object for exception handling. The below are the details to make it work.

a. Create a custom object called Exception with fields like stack trace( which would have the exception stack trace),apex class ( apex class name), source of error( web to lead form, integration, apex batch are possible values).

b. On your lead insert triggers, make sure you have a try catch exception handler and on the catch , insert the exception on the custom object.

c. Also have an email alert notify the admin or the developer team as soon as the exception happens on the web to lead form. This would help developers or admins to view the exception right away on the custom object and fix it rather than waiting for the business team to notify them. Imagine how much of this would be a time saver when you have a big campaign going on and all your web to lead forms fail!!!

So using the above techniques, you can easily fix web to lead issues and prevent problems. Here are the key takeaways from this blog.

a. Use the lead owner to your name temporarily to view the debug log to fix the error.

b. watch out for required fields, default fields and validation rules on leads newly created to identify the source of the problem.

c. Proactively create a custom object to log exceptions and have an automatic email alert to notify on web to lead failures.

I hope this blog has been of use to you and this should help to fix web to lead issues. Please feel free to email me at buyan@eigenx.com for any further questions.

About The Author

Hi there!
Thanks for visiting my blog. My name is Buyan Thyagarajan (Buyan47) . I am a Salesforce consultant specializing in higher education and helping businesses to measure business results , be proactive with their customers , prevent problems before hand and make the right decisions using Salesforce CRM. This blog would help you in the following way.
a. For Universities, my articles and tips would help you to increase your student recruitment, get better insights on your marketing campaigns and ensure student success by maximizing the features available in your salesforce org, integrate with your student information systems ( Banner, Ancor etc) and create a connected campus on the digital world.
b. For Salesforce admins, my articles would help you to be proactive with your salesforce crm, prevent problems and make the right decisions on different problems with salesforce.
c. For Business executives, my articles would help to measure business results with your salesforce crm, increase adoption and provide solutions for your business problems.
d. For IT executives and developers, my articles would help you on best practices on change management, provide insights on increasing your performance with your current development teams and guide you to make better architectural decisions with salesforce and salesforce1.
I am passionate about the following.
a. Software is meant to automate work but in reality IT is the most manual industry where programmers have to type those 100,000 lines of code everyday to make things work. Programmers get lost in the code and business folks wonder why the programmers are not getting it. I have some insights on this and in the process of publishing a book which should help in the following.
a. Help IT teams to be innovative and offer business value
b. Career pathway for programmers
c. Relevant things a business user can provide to IT to get things done quick.
Please feel free to post your comments on the site on my articles and any questions you have and I would be glad to answer it for you.
To reach me
Ph: 302-438-4097
m: buyan47@gmail.com