Changes

AJAX - API

1,058 bytes added, 19:33, 18 October 2022
no edit summary
The first three functions are the only functions required to utilize the API, the remaining two are utility functions which are used by the first three to carry out generic tasks, they do not need to be called directly.
 
'''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 query. '''strReturnFields''': Fields that you wish to extract in your query results, takes a string in format "strCDA_X_field_0_Y,strCDA_X_field_0_Z", where X is the form ID and Y is the field ID. You can find a full list of fields for a form/database by opening the [[Form - Field Mapping Management|field mapping management]] for it. '''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.  '''strGroupBy''': Group by clause for the query. Takes a string in the format of a MySQL Group By clause(the GROUP BY keyword itself should not be included.) '''strOrderBy''': Order by clause for the query. Takes a string in the format of a MySQL Order By clause(the ORDER BY keyword itself should not be included.) '''strLimit''': Limit to apply to the query, will cap the number of results brought back by the query to the number supplied. Takes an integer value.
strReturnFields'''strVariableToPopulate: Fields that you wish to extract ''' Variable in your which the results of the query resultswill be stored, takes a variable name as a string in format "strCDA_X_field_0_Y,strCDA_X_field_0_Z", where X is the form ID and Y is the field ID. You can find a full list Variable must be global(defined outside of fields for a form/database by opening the [[Form - Field Mapping Management|field mapping management]] for itany functions in your script).
strWhereClause'''strFunctionOnStart: Where clause to filter your ''' Code that will execute when the AJAX query results withis launched, takes a string in the format of a MySQL where clause condition(the WHERE keyword itself should not can be included.) For example, "intCDA_X_Id = 123" will return all records in form/database X where the record ID = 123left blank
strGroupBy'''strFunctionOnSuccess: Group by clause for ''' Code that will execute when the AJAX query. Takes returns with a string in the format of a MySQL Group By clause(successful result, should be used to launch whatever function will process the GROUP BY keyword itself should not data after retrieval but can be includedleft blank if desired.)
strOrderBy'''strFunctionOnFail: Order by clause for ''' Code that will execute when the AJAX query. Takes a string in the format of a MySQL Order By clause(the ORDER BY keyword itself should not returns with an unsuccessful result, can be includedleft blank.)
strLimit: Limit to apply to the query, will cap the number of results brought back by the query to the number supplied. Takes a whole number value.
strVariableToPopulateBelow is an example on how this function can be invoked.
strFunctionOnStart
strFunctionOnSuccessstrReturnFields = 'intCDA_7_Id,strCDA_7_field_0_1';
strFunctionOnFailfn_bxp_API_FormDataSearch(true, 'client_example', '', '', true, 7,strReturnFields,'(strCDA_7_field_0_5 = ' + document.getElementById('intCDA_Id').value + ' AND strCDA_7_field_0_1 > NOW())','','intCDA_7_Id',1000,'strApiRetrieveResult','console.log("API Retrieve Start")','fn_ADS_AfterRetrieveFutureBookings();','console.log("API Retrieve Fail")');
343
edits