XML形式のリクエスト(Reactor3)

If you are looking for a simple way to make a Request to Reactor from JavaScript, you can use the FRToolBox. https://splashdocs.atlassian.net/wiki/spaces/FusionReactor/pages/2202599558

Fusion Reactor ToolBox

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)

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.

 

Technical Overview

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:

 

<?xml version="1.0" encoding="UTF-8"?>
<reactor></reactor>

 

 

Reactor 3 supports three distinct operations when using XML calls:

 

Running an SQL request:

Reactor will run any arbitrary SQL you send through using this request. Here is an example of a find request.

<?xml version="1.0" encoding="UTF-8"?>
<reactor>

 

<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>

 

 

 

The following call to the FRTB object will automatically generate this request:

'my_table::XX222',
'my_table::XX111',
'my_table::another_field

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.

If using the request above, this is an example of a successful response.

 

<row><field name="XX222">My Oddly Named Field</field><field name="XX111"></Field><field name="">Some &lt;Escaped&gt; Contents</field></row><err>0</err>

If using the FRTB object, we will automatically check for any errors, and handle them accordingly. We will also parse the XML response into a JavaScript object which you can iterate over and directly access field values using the given field name.

The <row> element will be omitted if the SQL returns an empty result set.

Running a FileMaker Script:

Having Reactor run a Script in FileMaker is simple. Here is an example of a script request.

 

 

<databasename></databasename><scriptname>MyScript</scriptname><scriptparameter>MyParameter</scriptparameter>

 

 

 

 

 

 

The following call to the FRTB object will automatically generate this request:

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.

If using the request above, this is an example of a successful response. Unfortunately the script result cannot be returned at this stage.

 

<err>0</err>

Running a FileMaker Calculation:

 

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.

<calculation>Get ( FileName )</calculation >
<databasename ></databasename >
<layout></layout >

The following call to the FRTB object will automatically generate this request.

 

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.

 

If using the request above, this is an example of a successful response.

 

<result>My File Name</result>
<err>0</err>