Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Want to know more about the FRToolBox? 5. FRToolBoxの概要

Get the latest version of FRToolBox (see comments at the top of the file for changes):

...

Code Block
<script type='text/JavaScript' src='./libs/FRToolBox.js'></script>

FRTB Object

FRTB in ToolBox version 2.1 is not compatible with Reactor versions under v3.1. Please make sure you are using FRToolBox 2.1.3 or greater - v2.0.x is significantly different to what is described here.

...

You don't need to worry about converting native FileMaker fields to another format, and we don't need to worry about escaping any of the values for the SQL either... you don't even need to know what SQL is to understand what's going on here.

FRTB Function Reference

Methods used to create and execute a request on a FileMaker database.

Method Name

Parameters

Purpose

FRTB.request(d)

details object.

Create a FileMaker request. This request object may perform multiple database operations during the same request.

FRTB.find(f1,f2,f3,...)

Any number of fields to find.

Used find FileMaker records. Use in conjunction with .where(). Limited to a single request.

FRTB.create([f1,v1],[f2,v2],...)

Any number of field/value pairs.

Used to create FileMaker records. Limited to a single request.

FRTB.update([f1,v1],[f2,v2],...)

Any number of field/value pairs.

Used to update matched FileMaker record. Use in conjunction with .where(). Limited to a single request.

FRTB.remove(t)

Table occurrence name you want to delete records from.

Used to delete a FileMaker record. Use in conjunction with .where(). Limited to a single request.

FRTB.calc(c)

Calculation to perform.

Perform a FileMaker calculation and return the result to your JavaScript. Limited to a single request. Best used with a database name.

FRTB.script(s,p)

Script to run, Parameter to pass

Run a FileMaker script, and pass a parameter. Does not return script result. Must be used in conjunction with a Database Name.

Find Request

This method will create a find request which will retrieve data from the FileMaker database. You may use as many parameters to this method as you need. Each parameter should be a fully qualified field name.

...

The find would then fetch the internal FileMaker record ID, Field One, Field Two and Color. The records returned would only be the records with 'Green' in the color field. You can read more about the .filter() method below.

Create Request

This method will create a new record request, which will add a record to the FileMaker database. You may use as many parameters to this method as you need. Each parameter should be an array - the first element contains the fully qualified field name, and the second should contain the value you want to set into that field.

...

Again, you can chain any of the request object methods to the create request - although .filter(), .poll(), and .where() would each have no effect on the create request.

Update Request

This method will create a new update request, which can be used to modify any set of records in your FileMaker database. You may use as many parameters to this method as you need. Like the create request, each parameter should be an array - the first element contains the fully qualified field name, and the second should contain the value you want to set into that field.

...

All of the request object methods are available for use with the update request.

Calculation Request

This method allows you to perform a FileMaker calculation and return the result to your completion function. This can be used to set global variables, or get the results of FileMaker or Custom Functions etc. Anything that can be done in a FileMaker calculation engine, can be done with this method.

...

This request would evaluate the let statement, and would set the Global variable in your database.

Request Object Methods.

Method Name

Parameters

Purpose

request.where({w1},{w2}...)

Any number of where objects, or a single SQL WhereClause string.

Specifies the records you want to effect with this request. May be used in conjunction with filter if required.

request.filter(f)

A filter string.

Provides a user friendly syntax for providing arbitrary filters on a request. Can be used either independently or in conjunction with a 'where' statement.

request.send(d)

A details object, or a success callback handler

Starts the request - sends off the request and returns the result to the success handler (if successful).

request.debug(c)

Optional callback function.

Performs requests on the database to find out about missing or misnamed fields and tables. Then prints the output to the debug log, and a message dialogue, or returns an array of errors to the callback function if provided.

request.poll(f,t)

Poll handler function, and interval timer in milliseconds.

Lets you easily implement record modification, deletion and addition checking on a set of records.

Filter Method

You can implement a simple filter by chaining this method to your find, update, or delete request.

...

The filter can be used anywhere in the request chain and can (but is not required to) be used in conjunction with a traditional 'where' clause. The filter is essentially a simpler (but in some ways, not as powerful) method of creating or adding to a where clause.

Send Method

The send method allows you to fire off a request that you have previously constructed. This is usually the last method that you would add to a request chain.

...

The send method accepts a single parameter which can be either a completion function, or an object with request configuration details.

Debug Method

The debug method can be used by chaining this method to any request created using the FRTB object.

...

The default implementation (without supplying a callback) will show a popup dialogue message with a list of fields that may have caused errors in the find.


Poll Method

You can implement a poller by chaining this method to your find request.

...

You are able to put the .poll() wherever you like, and it will still work - even after the send. You could even start the poll inside the completion function.

FRTB Utility Methods

The FRTB object also provides you access to certain ancillary functions which may become useful in some circumstances.

Function Name

Parameters

Purpose

FRTB.setDefault(d,v)

The default to set, value to set it to.

Gives you the ability to set certain default values for use in the requests or other areas. E.g
FRTB.setDefault( 'DatabaseName', 'MyDB' )
would cause each request to use 'MyDB' unless explicitly overridden as a part of the request.

FRTB.getVersion()

Gets the current FRTB version number

FRTB.startDebugging()

Provides detailed debugging output to the console from the high and low level ToolBox functions.

FRTB.getLastError()

Gets the error object for the last request that returned an error from Reactor.

FRTB.getSQLDate(d)

The JavaScript date object you want to convert.

Convert a JavaScript date object to a formatted Date string for use in an SQL request.

FRTB.getSQLTime(d)

The JavaScript date object you want to convert.

Convert a JavaScript date object to a formatted Time string for use in an SQL request.

FRTB.convertDateTime(d)

The SQL date string you want to convert.

Converts a date string returned from the SQL engine in to a JavaScript date object.

FRTB.getTOName(f,e)

The field you want to get the TO from, whether to escape/quote it for an SQL string.

Parses the TO name from a FileMaker fully qualified field string. Allows you to return the raw TO name, or have the TO name escaped and quoted for use within an SQL string.

FRTB.getFieldName(f,e)

The field you want to get the Field from, whether to escape/quote it for an SQL string.

Parses the Field name from a FileMaker fully qualified field string. Allows you to return the raw Field name, or have the Field name escaped and quoted for use within an SQL string.

FRTB.getAction(a,i,c)

The action string you want to parse into an action object,
The action identifier to use in .performAction,
the completion function to run if using SetField (automatically gets the current value of that field).

Allow users the ability to flexibly supply or modify a simple database request. Gives the user the ability to set a field, or run a script with user provided parameters.

FRTB.performAction(i,p,c)

The action ID that you want to execute,
The parameter (or record set) you want to pass as a parameter,
The completion function to execute after performing this action.

Trigger the action, using the second value as a parameter.

FRTB Actions

An 'Action' is a standardized way of giving users the ability to supply their own method of responding to a particular interaction, or event. For example, in the Day Calendar, we give the FileMaker developer the ability to 'do something' when the end-user clicks on one of the appointments. To the FileMaker developer, we call this 'ActionOnApptSelect', and they can specify if they want that action to set a field, or run a script, and they can also specify the value they wan't to populate the field with, or pass to the script.

...

The above action, when performed, would set the field 'MyField' on the table occurrence 'MyTO' (as we haven't specified a value, however, it would empty the field.

Action Syntax

There are a few different options can be supplied for an action.

...

The performAction script will automatically extract the 'MyID' field from the passed data object, and will use that as the value to set the 'CurrentRecord' field.

Request Configuration

If you need to specify advanced configuration options for your request, you can do this by passing an object to the .send() method when sending your request to FileMaker.

...

Option

Default

Description

onsuccess

The completion function to call with the result on a successful request.

onerror

(internal request debugger)

The completion function to call on a failed request.

onrecordlock

Runs FR_Commit Record script and tries original request again.

The completion function to call when FileMaker reports a locked record.

creationvalues

Allows you to specify creation values in the format passed by the FileMaker plugin function 'bbdev_relationshipKeyBuilder'.

distinct

false

Add the 'DISTINCT' SQL keyword to your find request.

databasename

(current database)

The database name to run the request on. In the case of a script request, the script will be executed on this database. In the case of any other request, Reactor will check if the specified database is open in the front most window before executing the request, otherwise it will return an error.

layoutname

The layout name to run the request on. Reactor will check if the specified layout is open in the front most window before executing the request, otherwise it will return an error.

Debugging

The Fusion Reactor ToolBox contains a useful debugging console with advanced features to assist with your development. The FRTB object uses the debugger to provide developers with feedback on many of its functions. Find out more about JavaScript Debugging with Reactor. https://splashdocs.atlassian.net/wiki/spaces/FusionReactor/pages/2202501183 JavaScriptのデバッグ

FRToolBox.js.rct.2.5.5.zip

...