Difference between revisions of "JavaScript Self-Referencing Campaigns"

From All n One's bxp software Wixi

Jump to: navigation, search
Line 60: Line 60:
 
alert("Library did not load");
 
alert("Library did not load");
 
else {
 
else {
aryAjax_Settings[0] = "client_lev8marketing";
+
aryAjax_Settings[0] = "client_demo"; //The system to use
aryAjax_Settings[1] = "automated";
+
aryAjax_Settings[1] = "automatic"; //The automation username
aryAjax_Settings[2] = "processing";
+
aryAjax_Settings[2] = "passkey"; //The automation users password
aryAjax_Settings[3] = "2";
+
aryAjax_Settings[3] = "1"; //The Id of the campaign
aryAjax_Settings[4] = "strCDA_2_field_0_1";
+
aryAjax_Settings[4] = "strCDA_1_field_0_0"; //The search field
aryAjax_Settings[5] = document.getElementById('strCDA_2_field_0_1').value;
+
aryAjax_Settings[5] = "1"; //The search value
aryAjax_Settings[13] = document.getElementById('intCDA_Id').value;
+
aryAjax_Settings[13] = "-1"; //Id of the current record, used for delimiting and not repeating current case
aryAjax_Settings[14] = "true";
+
aryAjax_Settings[14] = "true"; //Click through to campaign?
aryAjax_Settings[15] = "strHistory";
+
aryAjax_Settings[15] = "divWarning"; //The id of the destination to which the table will be inserted
aryAjax_Settings[6] = "intCDA_2_Id,strCDA_2_field_1_3,strCDA_2_field_3_3,strCDA_2_LastDateTime,intCDA_2_StaffId,strCDA_2_Status,strCDA_2_Comments";
+
 
aryAjax_Settings[12] = "Case,Firstname,Surname,DateTime,Staff,Outcome,Comment";
+
//The fields to be returned into the array
 +
//The column names of those fields
 +
//The first field must always be the ID of the campaign
 +
aryAjax_Settings[6] = "intCDA_1_Id,strCDA_1_field_0_0,strCDA_1_field_0_1";
 +
aryAjax_Settings[12] = "Id,Field 1,Field 2";
 +
 
 
fn_Ajax_BE_Process();
 
fn_Ajax_BE_Process();
 
}
 
}

Revision as of 13:47, 20 March 2012

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 emoticon.


1 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

  • 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

Make sure NOTHING is ticked throughout the boxes below.

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.


2 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.

3 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.


<div id='strHistory'></div><script language=javascript type=text/javascript src=https://ww3.allnone.ie/library/javascript/fn_javascript_ajax_campaign.js ></script>

4 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.


/*--------------------------------------
// The Self Referencing Lookup settings	
--------------------------------------*/
function fn_SelfReferencing() {
	if (typeof aryAjax_Settings=="undefined")
		alert("Library did not load");
	else {
		aryAjax_Settings[0] = "client_demo"; 		//The system to use
		aryAjax_Settings[1] = "automatic"; 		//The automation username
		aryAjax_Settings[2] = "passkey"; 		//The automation users password
		aryAjax_Settings[3] = "1"; 			//The Id of the campaign
		aryAjax_Settings[4] = "strCDA_1_field_0_0"; 	//The search field
		aryAjax_Settings[5] = "1"; 			//The search value
		aryAjax_Settings[13] = "-1";			//Id of the current record, used for delimiting and not repeating current case
		aryAjax_Settings[14] = "true";			//Click through to campaign?
		aryAjax_Settings[15] = "divWarning";		//The id of the destination to which the table will be inserted

		//The fields to be returned into the array
		//The column names of those fields
		//The first field must always be the ID of the campaign
		aryAjax_Settings[6] = "intCDA_1_Id,strCDA_1_field_0_0,strCDA_1_field_0_1";
		aryAjax_Settings[12] = "Id,Field 1,Field 2";

		fn_Ajax_BE_Process();
	}
}

5 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

fn_SelfReferencing();


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