Included with the Fusion Reactor plugin is a suite of JavaScript functions called the Fusion Reactor Toolbox. These ‘helper’ functions are designed to handle some tasks like AJAX communications handling and SQL/XML query construction, so that you don’t have to take the time to build those into your own JavaScript solution.
The Fusion Reactor Toolbox is just an ordinary file of JavaScript functions, and objects. If you have included the file in the 'libs' folder of your BlackBox project directory, your JavaScript solution can access it at any time with a simple HTML command:
<script type='text/JavaScript' src='./libs/FRToolBox.js'></script>
XML (Extensible Markup Language) is a widely-used data format for transmitting and encapsulating data. This format is used in Reactor 3.1 to allow simpler and more accurate parsing of return data for Finds, and also to allow a simple and effective way for users to pass extra parameters and instructions to Reactor in one single request.
Reactor 3 adds support for talking to Reactor using XML. Content type for the request must be "text/xml", and the response from reactor is also XML. The body of the request should have valid, well structured XML. The format of the call is:
Reactor 3 supports three distinct operations when using XML calls:
<?xml version="1.0" encoding="UTF-8"?>
<reactor>
<fmsql>
<sql>SELECT XX222, XX111, another_field FROM my_table</sql><databasename>XYZ</databasename><layout>ABC</layout><field order="1">XX222</field><field order="2">XX111</field>
</fmsql>
</reactor>
FRTB.find(
'my_table::XX222',
'my_table::XX111',
'my_table::another_field
).send({'databasename':'XYZ', 'layout':'ABC'});
Valid tags for use under <fmsql>
| Tag Name | Function |
|---|---|
| sql | (required) Contains the SQL you want to execute. |
| databasename | (optional) Contains the name of the database you want to execute the query on. If this database is not currently active, the request will return an error. |
| layout | (optional) The name of the layout that the user should currently be on. If this layout is not currently active, the request will return an error. |
| field | (optional) Used to map field names on to values for the response, useful for finds. Order should be the order that this field appears in the SQL query. If a field name is not provided for a column, a blank name attribute is returned. |
<?xml version="1.0" encoding="UTF-8"?>
<reactor>
<fmsqlresult>
<row><field name="XX222">My Oddly Named Field</field><field name="XX111"></Field><field name="">Some <Escaped> Contents</field></row><err>0</err>
</fmsqlresult>
</reactor>
<?xml version="1.0" encoding="UTF-8"?>
<reactor>
<fmscript>
<databasename></databasename><scriptname>MyScript</scriptname><scriptparameter>MyParameter</scriptparameter>
</fmscript>
</reactor>
FRTB.script('MyScript', 'MyParameter').send();
Valid tags for use under <fmscript>
| Tag Name | Function |
|---|---|
| databasename | (optional) Contains the name of the database you want to execute the query on. If this database is not currently active, the request will return an error. |
| scriptname | (required) The name of the script that you want to run. |
| scriptparameter | (required) The script parameter that you want to pass to the script. |
<?xml version="1.0" encoding="UTF-8"?>
<reactor>
<fmscriptresult>
<err>0</err>
</fmscriptresult>
</reactor>
Reactor will run any FileMaker calculation in the users current context (whatever context the user is in at the time of execution). Here is an example of a calculation request.
<?xml version="1.0" encoding="UTF-8"?>
<reactor>
<fmcalculation>
<calculation>Get ( FileName )</calculation ><databasename ></databasename ><layout></layout >
</fmcalculation>
</reactor>
FRTB.calc( 'Get ( FileName )' ).send()
Valid tags for use under <fmcalculation>
| Tag Name | Function |
|---|---|
| calculation | (required) The calculation to run in the current user context. |
| databasename | (optional) Contains the name of the database you want to execute the query on. If this database is not currently active, the request will return an error. |
| layout | (optional) The name of the layout that the user should currently be on. If this layout is not currently active, the request will return an error. |
<?xml version="1.0" encoding="UTF-8"?>
<reactor>
<fmcalculationresult>
<result>My File Name</result><err>0</err>
</fmcalculationresult>
</reactor>
Comments