JavaScript Populate Drop Down List from another Campaign

From All n One's bxp software Wixi

Jump to: navigation, search

1 Overview

Centralising data in another campaign can make custom drop down lists far easier to manage.


A good example of this is a centralised product list which can change frequently.


To save time there is a standard block which can be used which uses the same AJAX engine as the Self Referencing Campaign Code and Data Injection code


1.1 The product list

Create a campaign to hold the product list


Build a campaign and in it type or load all of the products you would like to see in the drop down list.


The campaign should have two fields. The product name and a limiting / grouping field. The grouping field could be a yes / no question. i.e. if Yes, show it. If no, don't show it.


With the product campaign built, then note the field names of the product anme and the limiting / grouping field.


1.2 Hidden Div for Messages

In the campaign where you want the list populated : In the Instructions – Dial Out Instructions add


<div id='strHistory'></div>


1.3 Adding the drop down population code

In the campaign where you want the list populated : In the onLoad add


//--------------------------------------
// The Self Referencing Lookup settings   
//--------------------------------------
function fn_PopulateList() {
      if (typeof aryAjax_Settings=="undefined")
            alert("Library did not load");
      else {
            aryAjax_Settings[0] = "client_demo";               //Your system name
            aryAjax_Settings[1] = "demo";                      //The CMI API Username
            aryAjax_Settings[2] = "user";                      //The CMI API User password
            aryAjax_Settings[3] = "694";                       //The campaign which contains the product list
            aryAjax_Settings[4] = "strCDA_694_field_0_1";      //The field which contains the limiting / grouping factor
            aryAjax_Settings[5] = 'Yes';                       //The value to limit the responses by, in this case only yes items
            aryAjax_Settings[13] = -1;                         //Limit responses -1 do not limit
            aryAjax_Settings[14] = "false";                    //Draw a table
            aryAjax_Settings[15] = "strHistory";               //Where to draw error messages if any
            aryAjax_Settings[16] = "Populate";                 //Engine to use i.e. Populate
            //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] = "strCDA_694_field_0_0";      //The field in the product campaign to display
            aryAjax_Settings[12] = "";                         //Not used
            aryAjax_Settings[17] = "strCDA_421_field_0_12";    //The field in the current campaign into which the products will be inserted.
            fn_Ajax_BE_Process();
      }
}
fn_PopulateList() ;

Easy peasy!