343
edits
Changes
From All n One's bxp software Wixi
no edit summary
Below is an example on how this function can be invoked.
strReturnFields = '<span style="color: #00ccff;">intCDA_7_Id,strCDA_7_field_0_1</span>';
fn_bxp_API_FormDataSearch(true, '<span style="color: #ffcc00;">client_example</span>'<span style="color: #cc99ff;">, , , true</span>, <span style="color: #ff00ff;">7</span>,strReturnFields,'(<span style="color: #ff99cc;">strCDA_7_field_0_5 = ' + document.getElementById('searchField').value + ' AND strCDA_7_field_0_1 > NOW()</span>)','','intCDA_7_Id',<span style="color: #99ccff;">1000</span>,'<span style="color: #ff6600;">strApiRetrieveResult</span>','console.log("API Retrieve Start")','<span style="color: #00ff00;">fn_AfterRetrieveResults();</span>','<span style="color: #3366ff;">console.log("API Retrieve Fail")</span>');
In this example the API will attempt to query <span style="color: #ff00ff;">Form 7</span> from the <span style="color: #ffcc00;">client_example</span> system. <span style="color: #cc99ff;">The function will attempt to use the users current session to authenticate, the ID and Key fields are left blank as a result</span>.
<span style="color: #ff99cc;"><span style="color: #000000;">The results of the query will be stored in the global variable</span> <span style="color: #ff6600;">strApiRetrieveResult,<span style="color: #000000;"> and the function <span style="color: #00ff00;">fn_AfterRetrieveResults() </span>will run after a successful query result is returned, <span style="color: #3366ff;">otherwise, "API Retrieve Fail" will be printed to the console</span>.</span></span></span>
====fn_bxp_API_FormDataInsertUpdate( )====
This function is used to either insert a record into a database or update an existing record/records with new data.
This functions full header is:
function fn_bxp_API_FormDataInsertUpdate( blDisplayErrorText, strClientSystem, strAPI_Account, strAPI_Key, blAPI_DataX, intFormId, strFieldAndValueListing, strVariableToPopulate, strFunctionOnStart, strFunctionOnSuccess, strFunctionOnFail )
It takes the following parameters:
'''blDisplayErrorText:''' Toggles display of verbose error messages in the developer console, can be set to true or false.
'''strClientSystem:''' Name of the system you are accessing in BXP, takes a string in the format "client_X". Can be found by examining the URL of the system you are trying to interface with. For example, if the login URL for your BXP system is ww3.allnone.ie/client/client_exampleclient/main/login2.asp, your system name is "client_exampleclient".
'''strAPI_Account:''' The ID of the account you wish to use to authenticate with BXP for this interaction, this must be an active account in the target system, and the account itself must be correctly configured(see system configuration section above.) Should be left blank if using dataX(see blAPI_DataX section below.)
'''strAPI_Key:''' The matching security key for the account supplied via strAPI_Account. Should be left blank if using dataX(see blAPI_DataX section below.)
'''blAPI_DataX:''' Can only be used on pages that are built in BXP, such as forms or custom reports. Can be set to true or false. If set to true, the API will attempt to authenticate with the server using the login credentials of whoever is currently logged into the system. strAPI_Account and strAPI_Key should be left blank if this is set to true.
'''intFormId''': ID of the form/database you want to insert into/update.
'''strFieldAndValueListing''': A list of all fields in the form you want to update and the values you want to assign to them.
Takes a string in either of the following formats, depending on whether the user wants to enter a new record, or update an existing one. If a value for the record ID is specified, the API will attempt to update the record corresponding to that ID, otherwise it will insert a new record instead.
'''Insert'''
'&strCDA_X_Status="Example Status"&strCDA_X_field_0_Y="Example Value"'
'''Update'''
'&intCDA_X_Id=1&strCDA_X_Status="Example Status"&strCDA_X_field_0_Y="Example Value"'
'''strWhereClause''': Where clause to filter your query results with, takes a string in the format of a MySQL where clause condition(the WHERE keyword itself should not be included.) For example, "intCDA_X_Id = 123" will return all records in form/database X where the record ID = 123.
'''strVariableToPopulate:''' Variable in which the results of the query will be stored, takes a variable name as a string. Variable must be global(defined outside of any functions in your script).
'''strFunctionOnStart:''' Code that will execute when the AJAX insert/update is launched, can be left blank.
'''strFunctionOnSuccess:''' Code that will execute when the AJAX insert/update succeeds, can be left blank.
'''strFunctionOnFail:''' Code that will execute when the AJAX insert/update fails, can be left blank.
Below is an example on how this function can be invoked.
strReturnFields = '<span style="color: #00ccff;">intCDA_7_Id,strCDA_7_field_0_1</span>';
fn_bxp_API_FormDataSearch(true, '<span style="color: #ffcc00;">client_example</span>'<span style="color: #cc99ff;">, , , true</span>, <span style="color: #ff00ff;">7</span>,strReturnFields,'(<span style="color: #ff99cc;">strCDA_7_field_0_5 = ' + document.getElementById('searchField').value + ' AND strCDA_7_field_0_1 > NOW()</span>)','','intCDA_7_Id',<span style="color: #99ccff;">1000</span>,'<span style="color: #ff6600;">strApiRetrieveResult</span>','console.log("API Retrieve Start")','<span style="color: #00ff00;">fn_AfterRetrieveResults();</span>','<span style="color: #3366ff;">console.log("API Retrieve Fail")</span>');
In this example the API will attempt to query <span style="color: #ff00ff;">Form 7</span> from the <span style="color: #ffcc00;">client_example</span> system. <span style="color: #cc99ff;">The function will attempt to use the users current session to authenticate, the ID and Key fields are left blank as a result</span>.
The query will bring back the <span style="color: #00ccff;">record ID and value of field 1</span> for <span style="color: #99ccff;">up to 1000 results</span> <span style="color: #ff99cc;">where the date stored in field 1 is some time beyond the present date and the value stored in field 5 matches the value of the page element "searchField" </span>
<span style="color: #ff99cc;"><span style="color: #000000;">The results of the query will be stored in the global variable</span> <span style="color: #ff6600;">strApiRetrieveResult,<span style="color: #000000;"> and the function <span style="color: #00ff00;">fn_AfterRetrieveResults() </span>will run after a successful query result is returned, <span style="color: #3366ff;">otherwise, "API Retrieve Fail" will be printed to the console</span>.</span></span></span>