0

We have a web-to-lead form on website, which works just fine (correct data and all that), but now we need to tweak the 'flow' a bit and i'm not sure if that's even possible as i couldn't find anything on web related to that.

Basically, we have 5 topics (among other fields) and based on selected topic we need to create (or not create) the lead in SF. So for example, if "Topic #1", "Topic #2" or "Topic #3" is selected, everything should go as it currently does (leads should be created), but if "Topic #4" or "Topic #5" are selected we should skip lead creation.

I guess this could be done by manually tweaking the form (with js or something, based on selected topic), but i was wandering if there's a 'correct' (official) way of doing this?

Hopefully this makes sense :) Thanks in advance!

0

You can use JavaScript in your HTML, or you can use a Validation Rule to block the creation of the Lead on Salesforce.

1
  • Thanks for quick response! Will try the Validation Rule
    – J Boi
    Feb 9 at 17:01
0

With web-to-lead, the Lead is always going to hit your automated processes (Flows, Triggers, Validation Rules) once the form is processed by the server. So you can have Leads with Topics #4 or #5 error out to stop their creation on the server (for example, adding a DML error in an Apex Trigger). What a lot of people find as a very limiting issue with web-to-lead and web-to-case, is your ability to respond to the client that submitted the issue is virtually non-existent. When the form POSTs to the Salesforce server, it goes into an asynchronous queue and Salesforce just responds that it was received (HTTP 200). There's no mechanism to tell the client there's an issue. If you need to let the submitter know, then you will need to use client-side validation.

I think you'll want to approach this from both angles. Adding some client-side validation/checking with JavaScript will let people that fill out the form know that they need to do something else and adding the server-side check will prevent needless Leads from being generated (because you can't always trust that client-side validation works, especially if your form is public-facing).

Not the answer you're looking for? Browse other questions tagged or ask your own question.