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 email@example.com for any further questions.
Subscribe to our mailing list and get tips to maximize salesforce to your email inbox.
Thank you for subscribing.
Something went wrong.