LeadConduit by ActiveProspect

Validation with Custom JavaScript


Most lead validation can be accomplished by simply using the correct field types in your campaign, and setting up duplicate handling. In some cases, however, those facilities aren't enough. If you need to perform validation between fields (e.g., "if field #1 is greater than 18, then field #2 must be either 'xxx' or 'yyy'"), or vary acceptance criteria between lead providers, then a custom script may be the perfect solution.

A custom script can be set up on each campaign. From the campaign's page, access the script editor by clicking the "edit custom script" link. The syntax of the code you enter there is standard JavaScript, and is evaluated for each valid lead when it arrives in LeadConduit in that campaign. Note that other acceptance criteria, as set on the campaign's fields, will have already run. The script will not be executed for invalid leads.

The script has access to all the field values of incoming leads; Click the question-mark icon or type "ctrl-." (ctrl-period) to see a pop-up reference of how to access those values. They can thus be evaluated in any way necessary. You also have access to the core extensions provided by the Prototype JavaScript framework, with the exception of browser related features.

If a lead should need to be invalidated by the script, the script can invoke the function "lead.invalidate()", which takes a single string parameter: the reject reason.

In this example, the campaign includes a field called "program_of_interest" and another called "education_level". This script will invalidate the lead if program_of_interest is "EMS" but education_level is not one those listed:

if (lead.program_of_interest == "EMS") {
   var level = ["College Bachelor's", "College Master's", "College Doctorate"];
   if (!level.include(lead.education_level))
      lead.invalidate("EMS program requires Bachelor's or higher");

last updated 10/1/2009 7:08 PM