JavaScript Self-Referencing Campaigns

Self Referencing Campaigns are extremely useful tools to allow campaigns add dynamic information to their work day.

A self referencing data table shows all the previous records that match pre-specified search criteria.

The system uses AJAX, another word for complicated client side JavaScript. Being who we are in the BE support team, we've prepacked the whole lot and made it a couple of lines of work :).

Step 1. Create a user for automated lookups
We need a dedicated secure user in order to be used as the user to do these lookups.

The suggested user is called Make sure NOTHING is ticked throughout the boxes below.
 * Firstname: Automated
 * Surname: Lookup
 * Password: make this incredicbly long and complicated, it will never be used.
 * IP Range: This is vitally important. This system will only work from the IP addresses specified here.
 * External System Id: automatic
 * External System Key: passkey

You also need to do the security jobs for the user.


 * 1) Add the user to the campaign.
 * 2) Ensure the user is added to the Everyone group in the Organogram in SAM.

Step 2. Modify the campaign for external lookups
By default the campaign will not be able to be searched externally. We need to enable this.

Main Menu > Database Management > Database - Primary Details > Campaign - Edit > Choose your campaign > Advanced Options subsection > Change "Externall Available" from Private to Public

Update the campaign.

Step 3. Create a location in the script to display the results.
The results have to be shown somewhere. This, to date, has been puti n the Notes section of a Section Header, somewhere in the script so..... add the following to a Notes section of a Section Header in your script.

Step 4. Create the Self-Referencing Function.
You need to modify the code below for it to work for you.

This gets placed in the JavaScript onLoad of the campaign. Main Menu > Database Management > Database - Primary Details > Campaign - Edit > Choose your campaign > JavaScript onLoad subsection > Opening Code execution box.

Step 4.1. Create the Self-Referencing Function for use on an on change event on a (Text box,Drop down list, etc).
You need to modify the code below for it to work for you.

This gets placed in the JavaScript onLoad of the campaign. Main Menu > Database Management > Database - Primary Details > Campaign - Edit > Choose your campaign > JavaScript onLoad subsection > Opening Code execution box.

Step 5. Call the Self-Referencing Function.
You now need to add the automated lookup to a field. This is usually done on the onChange of the value being looked up. i.e. if you search on a phone number, edit the phone number question and in the onChange of the box, add

And that should be it and you ready to test and use.

Step 6. Data Injection Campaigns
It is also possible to do data injection campaigns using this functionality. JavaScript_Data_Injection_Campaigns