AJAX - API BXP2
From All n One's bxp software Wixi
Contents
1 BXP 2 - AJAX API
1.1 Overview
The BXP 2 AJAX Javascript API provides a flexible and simple interface between BXP databases and any external page you would like to build or integrate into. This API can also be used on pages within a BXP system to access information for cross-campaign or reporting purposes.
This article will cover an overview of the functions available in the API as well as a detailed breakdown of the parameters they accept and what each does. We will also cover the necessary configuration required to ensure a database is accessible through the API.
Users are recommended to have a basic understanding of MySQL and Javascript before attempting to utilise this API.
1.2 Functionality
The BXP 2 AJAX API currently provides the ability to pull data out of BXP 2 Campaigns and push new data into new or existing records in BXP 2 Campaigns.
System level data such as user account information or campaign meta data is not available through the API, only custom campaigns built using BXP 2s Campaign Management suite can be queried.
1.3 Parameter Format
The BXP 2 AJAX API utilizes parameter destructuring to process its input parameters. With this method, you pass your arguments to a function inside an object instead of directly. This approach allows us to continue to develop and improve the BPX 2 API while minimizing the risk of breaking existing integrations.
1.4 Functions
The BXP 2 AJAX API currently provides two functions;
1.4.1 fn_bxp_API_FormDataSearchV2
Searches a BXP 2 Campaign defined by the parameter intFormId
1.4.2 Parameters
blDisplayErrorText - Boolean to Toggle display of verbose error messages. intFormId - Integer that specifies the Campaign to insert into or update. strReturnFields - String defining the list of fields the API call will return, comma separated. strWhereClause - String defining a custom where clause to filter the API result with. strGroupBy - String defining a custom group by clause to group the API result by. Can be left blank. strOrderBy - String defining a custom order by clause to order the API result by. Can be left blank. strLimit - String to define a limit clause to limit the number of results the API will return. strVariableToPopulate - String containing the name of a variable where the result of the API call will be inserted. This needs to be defined as a Global Variable in your Javascript file. strFunctionOnStart - Function to run when the API call begins, can be left blank. strFunctionOnSuccess - Function to run when the API call returns successful, can be left blank. strFunctionOnFail - Function to run when the API call returns unsuccessful, can be left blank.
1.4.3 Example
objParams = { blDisplayErrorText: true,
intFormId: 1,
strReturnFields: "strcData_1,strcData_2",
strWhereClause: "strcData_3 = 'Test'",
strGroupBy: "",
strOrderBy: "",
strLimit: "1000",
strVariableToPopulate: "aryLookupResponse",
strFunctionOnStart: "",
strFunctionOnSuccess: "console.log('Results:' + aryLookupResponse.toString());",
strFunctionOnFail: ""
}
fn_bxp_API_FormDataSearchV2( objParams );
1.4.4 fn_bxp_API_FormDataInsertUpdateV2
</div> Inserts a new record into a BXP 2 Campaign or updates an existing one, defined by the parameter intFormId.
1.4.5 Parameters
blDisplayErrorText - Boolean to Toggle display of verbose error messages. intFormId - Integer that specifies the Campaign to insert into or update. strFieldAndValueListing - Object containing a list of key:value pairs for each field to be given a new value. strVariableToPopulate - String containing the name of a variable where the result of the API call will be inserted. This needs to be defined as a Global Variable in your Javascript file. strFunctionOnStart - Function to run when the API call begins, can be left blank. strFunctionOnSuccess - Function to run when the API call returns successful, can be left blank. strFunctionOnFail - Function to run when the API call returns unsuccessful, can be left blank.
1.4.6 Example
let objParams = {
blDisplayErrorText: true,
intFormId: 1,
strFieldAndValueListing: { strcData_1: "Test Update" },
strVariableToPopulate: "aryResponse",
strFunctionOnStart: "",
strFunctionOnSuccess: "console.log('API Insert/Update Success.');",
strFunctionOnFail: "console.log('API Insert/Update Failed.');"
}
fn_bxp_API_FormDataInsertUpdateV2( objParams );