Changes

AJAX - API

743 bytes added, 16:06, 20 October 2022
Configuration
==Configuration==
====Form Configuration====
When attempting to utilize this library you will need to first configure the from or forms you intend to try and interact with to ensure they are publicly accessible. To do this you will either need to have Form Edit permissions for the target BXP system, as well as access to the specific form(s) you wish to use. If you do not have these permissions, ask a system administrator for assistance with this task.
Open the Advanced Settings for the form(s) you need to interact with through the API and select the External tab. Here you will find the settings for Externally Available and Public Outcome.
====User Account Configuration====
If you are attempting to use this library on a page built inside of BXP(such as keystat or form) you can simply use the DataX option when executing an API call to authenticate using the current users login credentials.
If however you are using the API from a page external to BXPor if you want all of your interactions to be performed by a specific user account, you must use supply the security credentials for a valid, active account in the target BXP system. By default BXP user accounts do not have external security credentials defined, so they may need to be set up for the account you wish to use. As with form configuration, you will need to either have User Account Edit permissions in BXP, or request that an admin for the target system assist you.
To check the security credentials for a BXP account, open the account for editing and then open the Primary Security Details tab. Both the External System ID and External System Key fields must be set in order for the account to be able to authentic authenticate through the API.
[[File:ExternalSettings2.jpg|800px]]
'''External System Key: '''Must be set. We strongly advise using a secure, generated key with both uppercase, lowercase and numerical characters.
 
 
====Form Access Permissions====
Whether authenticating using the the current BXP user's session or by supplying a specific accounts security credentials, the API will reject any attempts to query or update a Form if the user account being used does not have access permissions to it.
 
See our article on [[Form - Security Access|form access]] for more information on how to manage form access permissions for user accounts. As with form configuration, you will need both Form Edit permissions for the target BXP system as well as access to the specific form(s) you wish to use. Otherwise, request assistance from an administrator of the target BXP system.
==Functions==
strFieldsToUpdate = <span style="color: #ff99cc;">'</span><span style="color: #99ccff;">&intCDA_161_Id=100</span><span style="color: #ff99cc;">&strCDA_161_Status="Application form completed"&strCDA_161_field_0_0="' + document.getElementById('FieldA').value + '"&strCDA_161_field_0_1="' + document.getElementById('FieldB').value + '"&strCDA_161_field_0_12="' + document.getElementById('FieldC').value + '"&strCDA_161_field_0_13="' + document.getElementById('FieldD').value + '"'
<span style="color: #000000;">strFieldsToInsert =</span> <span style="color: #993366;">'</span><span style="color: #ff99cc;"><span style="color: #993366;">&strCDA_161_Status="Application form completed"&strCDA_161_field_0_0="' + document.getElementById('FieldA').value + '"&strCDA_161_field_0_1="' + document.getElementById('FieldB').value + '"&strCDA_161_field_0_12="' + document.getElementById('FieldC').value + '"&strCDA_161_field_0_13="' + document.getElementById('FieldD').value + '"'</span>
</span></span>fn_bxp_API_FormDataInsertUpdate(true, '<span style="color: #ffcc00;">client_example</span>', '<span style="color: #cc99ff;">API_Application_FormAPI_Example</span>', '<span style="color: #cc99ff;">__29dhtbfji__29dhtbfji__29dhtbfji<span style="background-color: #ffddcc;">__123456789!!</span></span>', <span style="color: #cc99ff;">false</span>, '<span style="color: #ff00ff;">161</span>', strFieldsToUpdate, '<span style="color: #ff0000;">strApiUpdateResult</span>', 'console.log(\'API Insert start\')', '<span style="color: #339966;">console.log(\'API Insert Success: \' + strApiInsertResult);fn_AfterSubmit();</span>', '<span style="color: #3366ff;">console.log(\'API Update Fail: \' + strApiInsertResult)</span>');
In this example the API will attempt to update <span style="color: #ff00ff;">Form 161</span> from the <span style="color: #ffcc00;">client_example</span> system. <span style="color: #cc99ff;">The function will attempt to use the the ID and Key for API_Application_Form API_Example to authenticate</span>.
<span style="color: #ff99cc;"><span style="color: #000000;">The update will</span> set the Status to "Application form completed" and the values of fields 0,1,12 and 13 to the values of page elements FieldA through FieldD respectively</span> <span style="color: #99ccff;">for record ID 100. <span style="color: #000000;">Alternatively, if the variable</span> <span style="color: #993366;">strFieldsToInsert</span> <span style="color: #000000;">were used instead of strFieldsToUpdate,</span> <span style="color: #993366;">a new record with the same values as above would be inserted into the form instead.</span></span>
<span style="color: #ff99cc;"><span style="color: #000000;">The results of the update will be stored in the global variable</span><span style="color: #ff99cc;"> </span><span style="color: #ff6600;">strApiUpdateResult</span><span style="color: #ff6600;">, <span style="color: #339966;">"API Update Success will be printed to the console"</span><span style="color: #ff6600;"> </span><span style="color: #000000;">and the function <span style="color: #00ff00;"><span style="color: #339966;">fn_AfterSubmit()</span> </span>will run after a successful result is returned, <span style="color: #3366ff;">otherwise, "API Update Fail" will be printed to the console</span>.</span></span></span>
 
 
====fn_bxp_API_eCourseSearch( )====
348
edits