== Overview ==
== How it works =Functions Available (Reference Information) =
As part of the functionality there are a number of predefined functions. These are set in aryAjax_Settings[[File:AJAXoperation001.png]16]
# When you log into bxp and start a form, the page will draw based on the Form (Web Page is built on Form 1).# As part of the code of the page you can include AJAX functionality into the formfunctions are detailed, done through the Advanced Settings > JavaScript onLoad. (AJAX is drawn into the page.)# When the page is executed in the clients browser, the AJAX can be activated and it works through please use the BEAPI to access data in any number of formslinks where available for further details.
== Array of Parameters Listing (Displays) ==
To save {| class="wikitable"|-! style="width:20%" | Function! style="width:40%" | Link! style="width:40%" | Description|-| Table || [[AJAX_-_Function_-_Table]] || Draws a lot listing of repeating code, records from another form facilitating passed parameters. e.g. List contacts in a table in company form.|-| LiveSearch || [[AJAX_-_Function_-_LiveSearch]] || The ability to put a single row of data with the ability to put a custom function on the majority button.|-| LiveSearchTable || [[AJAX_-_Function_-_Live_Search_Table]] || An extension of the functionality LiveSearch function but displays the data in a table format, rather than one string.|-| LiveSearchKeyStatData || [[AJAX_-_Function_-_LiveSearchKeyStatData]] || Return of data in a delimited string suitable for use in the same parametersKeyStats module. |}
All of the functionality is coded into the publicly available library fn_javascript_ajax_campaign.js. https://ww3.allnone.ie/library/javascript/fn_javascript_ajax_campaign.js
== Lookup functions ==
bxp creates an array to store the parameters. Not all parameters are being used by all functions.
{| class="wikitable"
|-
! style="width:20%" | Function
! style="width:40%" | Link
! style="width:40%" | Description
|-
| Append || [[AJAX_-_Function_-_Append]] || Lookup data from a form and append it to data in a field in the current form
|-
| Insert || [[AJAX_-_Function_-_Insert]] || Lookup data from a form and insert it into a field in the current form
|-
| InsertCount || [[AJAX_-_Function_-_InsertCount]] || Lookup a summative count of records from a form and insert the counted amount into a field in the current form
|-
| Populate || [[AJAX_-_Function_-_Populate]] || Wipes a drop down list then populates the contents of the drop down list with values from another form. Text and value of the drop down list will be the same.
|-
| Populate_AltList || [[AJAX_-_Function_-_Populate_AltList]] || Wipes a drop down list then populates the contents of the drop down list with values from another form. Text and value of the drop down list can be populated with different values.
|-
| PopulateNoClear || [[AJAX_-_Function_-_PopulateNoClear]] || Adds to the contents of a drop down list with values from another form. Text and value of the drop down list will be the same.
|-
| PopulateNoClear_AltList || [[AJAX_-_Function_-_PopulateNoClear_AltList]] || Adds to the contents of a drop down list with values from another form. Text and value of the drop down list can be populated with different values.
|}
<source lang="javascript">
//==Record Management ==============================================================// Variable Initialisation//================================================================//Initialising the settings array, and for clarity explaining the elements of the array.//Simply copy this block of data into your code and replace the values with your system values//Not that the automation user MUST have an IP Address set for the system to work//-----------------------------------------------------------------------------------------aryAjax_Settings[0] = "client_demo"; //The system to usearyAjax_Settings[1] = "demo"; //The automation usernamearyAjax_Settings[2] = "password"; //The automation users passwordaryAjax_Settings[3] = "1"; //The Id of the campaignaryAjax_Settings[4] = "strCDA_1_field_0_0"; //The search fieldaryAjax_Settings[5] = "1"; //The search valuearyAjax_Settings[13] = "-1"; //Id of the current record, used for delimiting and not repeating current casearyAjax_Settings[14] = "true"; //Click through to campaign?aryAjax_Settings[15] = "divWarning"; //The id of the destination to which the table will be insertedaryAjax_Settings[16] = "Table"; //The default option is to create a table to display. The other options is Insert. Which will insert the values into the relevant fields.
//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";
aryAjax_Settings[17] = "intCDA_1_Id,strCDA_1_field_0_0,strCDA_1_field_0_1"; //For insertion, what local campaign fields will the data be transferred into.
//-----------------------------------------------------------------------------------------
// Extra settings fields used by the function, but made available globally for testing
aryAjax_Settings[7] = ""; //Constructed URL for retrieveing data
aryAjax_Settings[8] = "-1"; //Error Status
aryAjax_Settings[9] = ""; //Error Translation
aryAjax_Settings[10] = "-1"; //Record count
aryAjax_Settings[11] = ""; //Alternate Destination if required. Constructed just before use
//-----------------------------------------------------------------------------------------aryAjax_Settings[18] {| class= "truewikitable"; //Show table if empty? By default always show something.aryAjax_Settings[19] |-! style= "width:20%"; //Custom sort order if needed| FunctionaryAjax_Settings[33] ! style= "width:40%"; //Custom sort orderDESC | LinkaryAjax_Settings[20] ! style= "width:40%"; //Custom group by if needed| Description|-aryAjax_Settings| dbDeleteRecord || [21[AJAX_-_Function_-_dbDeleteRecord] = "false"; //Limit to My Records only] || To allow the deletion of a CDA record from another form.aryAjax_Settings[22] = ""; //Auto Login |- SystemaryAjax_Settings| dbInsertRecord || [[23AJAX_-_Function_-_dbInsertRecord] = ""; //Auto Login ] || To allow the insertion of a CDA record into another form.|- UseraryAjax_Settings| dbUpdateRecord || [[24AJAX_-_Function_-_dbUpdateRecord]] = ""; //Auto Login || To allow the update of a CDA record in another form.|- SessionId|}
//--Live Search----------------------------------------------------------------------------aryAjax_Settings[25] = ""; //Field to Update (Id Value)aryAjax_Settings[26] How it works = ""; //Function After UpdatearyAjax_Settings[27] = ""; //Field to Update (Display Text)
//--Post Data Rerrieval Execution----------------------------------------------------------
aryAjax_Settings[28] = ""; //Generic function call
//--Live Search Format Options-------------------------------------------------------------aryAjax_Settings[29] = ""; //Buttons in the first column or the last column --> First/LastaryAjax_Settings[30] = ""; //Multi - button functionality --> Two coloursaryAjax_Settings[31File:AJAXoperation001.png] = ""; //Button Text (multi separated by ',' --> XXXXXXXX,XXXXXXXaryAjax_Settings[32] = ""; //Value for matching to show button 2 --> XXXXXXX
//--Order Options----------------------------------------------------------------------------
aryAjax_Settings[33] = ""; //Sort decending
//--AJax Data Insert/Update/Delete Parameters----------------------------------------------------------------------------aryAjax_Settings[34] = ""; //Fields to insert toaryAjax_Settings[35] = ""; //Values to insert# When you log into bxp and start a form, the page will draw based on the Form (Web Page is built on Form 1).aryAjax_Settings[36] = ""; //Field to search on# As part of the code of the page you can include AJAX functionality into the form, done through the Advanced Settings > JavaScript onLoad. (AJAX is drawn into the page.)aryAjax_Settings[37] = ""; //Value # When the page is executed in the clients browser, the AJAX can be activated and it works through the BEAPI to search witharyAjax_Settings[38] = ""; //Add a CClaccess data in any number of forms.
</source>
== Functions Available =Array of Parameters =
As part of the functionality there are a number of predefined functions. These are set in aryAjax_Settings[16] As the functions are detailed, please use the links where A full listing is available for further details. * Append* dbDeleteRecord* dbInsertRecord* dbUpdateRecord* Insert* InsertCount [[JavaScript_AJAX_Functions]]* LiveSearch [[JavaScript_LiveSearch]]* LiveSearchTable [[JavaScript_AJAX_Functions]] [[Java_Script_Live_Search_Table]]* Populate [[JavaScript_Populate_Drop_Down_List_from_another_Campaign]]* Populate_AltList here [[JavaScript_AJAX_FunctionsAJAX_-_Full_Array_of_Paramters]]* PopulateNoClear* PopulateNoClear_AltList
* [[JavaScript_-_Interactive_Record_Locking]]
* [[Java_Script_Hospital_Red_Green]]
== Security ==One useful concept that AJAX can facilitate is Centralised Listing [[Centralised_Listing]]
Security is very important to bxp and BEAPI calls should be no less secure. For this reason there are a number of security concepts to be considered.
The AJAX makes calls to the BEAPI, hereto referred to as "The Call". When the Call is made, it requires a username and password. That user must have access to the form. In using the AJAX there are two possible options. # Use a set username and password# Use a dynamic username and password The set username and password is more secure but must have specified white listed IP addresses it can be used from. The user must be granted access to the form containing the data. This also allows this user to have all functional access removed but still allow content access. This is the more secure preferred option. * aryAjax_Settings[0] = "client_demo"; * aryAjax_Settings[1] = "demo"; * aryAjax_Settings[2] Security = "password"; Set user location can be difficult to manage if users move location often or there is no static IP address available. There is a dynamic security setting, which requires the current user to have access to the form, but the engine uses the current users login, to access the form. * aryAjax_Settings[22] = document.getElementById('intSystemGenerated_CompanyId').value; * aryAjax_Settings[23] = document.getElementById('intSystemGenerated_UserId').value; * aryAjax_Settings[24] = document.getElementById('intSystemGenerated_LoginKey').value; The Call is made using a secure HTTP Post using form variables and not querystring parameters. This provides maximum security for the data being sent. The error code will return 0 for success and the following codes for errors.
* -1 = No settings initialised. Please set the settings on your page.* -2 = Settings not initialised. Please set the settings on your page.* -3 = Settings cannot be blank. Please check the settings on your page.* -4 = Server response not formatted correctly. <br />Please refresh the page and try again. <br />Error Code This is further detailed here [ " + aryAjax_Settings[3] + " AJAX_- " + aryAjax_Settings[5_Security_engine] + " ]* -5 = No data fields specified. Please set the settings on your page.* -6 = No display fields specified. Please set the settings on your page.* -7 = AJAX transport failure. Please refresh the page and try again.* -8 = AJAX initialisation failure. Please refresh the page and try again.
There is often error messages to display when using the engine for For a variety of reasons including: incorrect username, password, IP address restricted, etc.more indepth discussion on this area [[AJAX_-_Error_messages_and_troubleshooting]]
For this reason, it is possible to write back to screen the error messages into a user specified div. You create the div on your form where you like it and put id="" in it.
If you set aryAjax_Settings[15[Category:Topic:JavaScript]][[Category:Topic:Start Here]] = 'divYourName'; then the error messages will write to the innerHTML of the div.