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
Yuvi TrialYuvi Trial 

Capture records from web-to-lead and store it in custom objecct

Hi All,
When web-to-lead record is rejected based on validations , That records must be capture the values for all fields on the custom object.
I have tried with @future, SaveResult concept to capture web-to-lead records, But unable to capture rejected web-to-lead records by validations. 
Sumeet_ForceSumeet_Force
Hi Yuvi,
Webtolead and webtocase are inbuilt mechanisms and thus provide very less options when dealing with any validation errors.

However, there are workarounds to it:
1. Instead of prebuilt webtolead, you can use inbound email handler class, that can do a lot of business logic handling for your validations and can add error records in custom objects.

2. If you have just 2-3 validation fields, then you can modify validation itself so that validation is applied only for other scenarios and not for web-to-lead records. Just in case, that fits your requirement.
Yuvi TrialYuvi Trial
Thanks for your reply Sumeet. Let me explain with scenario.

I have added LastName, Company, LeadStatus, Email, Phone in the Web-to-Lead form.
Also implementing validation i.e while creating the lead, If LeadStatus is Working-Contacted. Error message will display.
While submitting the form with leadstatus = Working-Contacted, Validation rule wont allow to store the lead records into the salesforce. I want to store all the records which has the LeadStatus is Working-Contacted to the Custom Object. 

Here my question is Whether it is possible or not? If Possible, How to capture those records and store in Custom Object?
Tavva Sai KrishnaTavva Sai Krishna
Hi Yuvi,

In your Scenario, create a checkbox in the lead object. also change the validation rule such that 
AND(Checkbox__C = false,leadstatus = Working-Contacted)
In the web page use the hidden field which will mark the checkbox value as true. and remove the checkbox__C field from the standard pagelayout.

Hope this solution works well in your scenario. 

Let me know with the errors if you face any ,

Regards,
Sai Krishna Tavva.
 
Yuvi TrialYuvi Trial
Hi Sai Krishna,
I have placed the checkbox which is not visible in page layout  and wrote the validation rule as you mentioned. While i'm submitting the web-to-lead form, that form's record will be rejected due to validation rule. So it won't store inside the lead instead of that I want that rejected record to be captured in Custom Object. Still i am not able to find the solutions.