KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the Bridge Object to Update Records
PRODUCT: 4D Web 2.0 Pack | VERSION: 11.2 | PLATFORM: Mac & Win
Published On: November 3, 2008

PLEASE NOTE: This Tech Tip applies to 4D Ajax Framework v11 Release 2

The Bridge is a 4D Ajax Framework component that enables direct communication between 4DAF front end objects and 4D. With the Bridge's API, you can invoke 4D record updates from the front end with a little JavaScript, without having to manipulate the Data Grid or other high level 4DAF object.

With the Bridge you can add, modify or delete a 4D record with the following JavaScript calls:

dax_bridge.addRecord(selectionName, fieldArray, valueArray, handler, variable);

dax_bridge.modifyRecord(selectionName, fieldArray, valueArray, recordId, handler, passedVariable);

dax_bridge.deleteRecords(selectionName, recordId(s), handler, passedVariable);


* selectionName is a table, view or DCS.
* fieldArray is a JavaScript array of field names to update in the record
* valueArray is a JavaScript array of field values to update in the record
* handler (optional) is a JavaScript function that's called after 4D responds to update
* passedVariable (optional) is a custom Javascript object of your choosing or making that is passed to the handler function; just one example would be passing your Data Grid object, whose data view you can then refresh with a query in the handler after the Bridge update is complete.

* recordId(s) (for modifyRecords and deleteRecords only) is a JavaScript array of record ID numbers, in the format [tableNum][recordNum]. One example of obtaining a record ID would be responding to the Data Grid object's onDataRowClick event, which passes recordId as a parameter to your handler function.

Here are simple examples of usage for all these commands:

dax_bridge.addRecord('Employees', ['FirstName', 'LastName', 'Position'], ['Mary', 'Smith', 'Accountant']);

dax_bridge.modifyRecord('Employees'', ['FirstName', 'Position'], ['Marie', 'Sr. Accountant'], '[3][25]');

dax_bridge.deleteRecords('myTable', ['[3][25]', '[3][28]']);


In this example hard-coded arrays are used. An array can first be initialized and populated in your JavaScript code, then simply passed by its name in the Bridge calls.

For more information see the Bridge 2.0 documentation in the Daxipedia:

http://daxipedia.4d.com/index.php/Bridge_2.0