Skip to main content

Base

Last updated 31/01/2023

Five Object

The Five object is the main object that will help you interact with Five. The Five object is a standalone entity with the following properties and functions.

Properties

field

The field property is used on the Five object and will return the value associated to the field ID on the current form.

five.field.<fieldID>

form

The form property is used on the Five object and will return the value associated to the combination of the form ID and the field ID for the form in the stack.

five.form.<formID>.<fieldID>

stack

The stack property is used on the Five object and will return the primary key for the associated table in the stack.

five.stack.<tableId>.<primaryKey>

variable

The variable property is used on the Five object and will return values set from the setVariable() function.

five.variable.<variableID>

headers

parameters


Functions

actionID()

The actionID() is a function that returns the current action ID.

Function Signature
actionID() : string;

addFilter()

The addFilter() is a function that adds a key and its value to the Five stack.

Function Signature
addFilter(keyName: string, key: string) : void;

clearVariable()

The clearVariable() is a function that clears a previously set global variable.

Function Signature
clearVariable(name: string) : any;

clientAddress()

The clientAddress() is a function that returns the network address of the client.

Function Signature
clientAddress() : string;

commit()

The commit() is a function that commits a database transaction.

Function Signature
commit(tx: Transaction) : FiveError;

createError()

The createError() is a function to return an error with an optional message and notification parameters.

Function Signature
createError(currentResult: FiveError | message: string, [message: string, [notification: string]]) : FiveError;

currentUserKey()

The currentUserKey() is a function to return the current logged in user.

Function Signature
currentUserKey() : string;

currentUserRecordKey()

The currentUserRecordKey() is a function that returns the user record associated to the current user.

Function Signature
currentUserRecordKey() : string;

date()

The date() is a function used on the five object that returns the current local date as a string.

Function Signature
date(): string;

dateTime()

The dateTime() is a function used on the five object that returns the current local date and time as a string.

Function Signature
dateTime(): string;

dateTimeLocalToUTC()

The dateTimeLocalToUTC() is a function used on the five object that converts a local date and time to a UTC timestamp.

Function Signature
dateTimeLocalToUTC(localDateTime: string) : string;

dateTimeUTCToLocal()

The dateTimeUTCToLocal() is a function used on the five object that converts a UTC timestamp to a local date and time.

Function Signature
dateTimeUTCToLocal(UTCDateTime: string) : string;

displayCustomForm()

The displayCustomForm() is a function used on the five object that displays a custom form.

Function Signature
displayCustomForm(actionID: string) : void;

executeAction()

The executeAction() is a function that executes an action on the Five server.

Function Signature
executeAction(actionID: string, [context: any, [at: Date]]) : FiveError;

executeFunction()

The executeFunction() is a function that executes a function on the server.

Function Signature
executeFunction(
name: string,
variables: Map<string, any>,
file: File,
actionKey: string, //Deprecated, not used
functionKey: string,
[ onResultsCallBack: (results: any) => void) : void ])

executePlugin()

The executePlugin() is a function that executes a plugin by its Plugin ID on the Five Server.

Function Signature
executePlugin(pluginID: string, context: any) : PluginResult;

executeQuery()

The executeQuery() is a function that executes SQL statements on the Five server and returns results.

Function Signature
executeQuery([transaction,] query[, limit[, ...parameters]]) : QueryResult;

getDatabaseConnectionByID()

The getDatabaseConnectionByID() is a function that returns a database connection by ID.

Function Signature
getDatabaseConnectionByID(databaseID: string) : DatabaseConnection;

getFormField()

The getFormField() is a function that returns the field associated to the field ID on the form ID in the stack.

Function Signature
getFormField([FormID: string,] fieldID: string) : any;

getMetadata()

The getMetadata() is a function that provides metadata from a field.

Function Signature
getMetadata([ formID: string ], fieldID: string, queryFieldID: string) : any;

getOption()

The getOption() is a function that returns a value of an option configured in the Options field against the instance of the running application.

Function Signature
getOption(key: string) : string;

getSelectedMenuID()

The getSelectedMenuID() is a function that returns the current selected menu ID.

Function Signature
getSelectedMenuID() : string;

getStackField()

The getStackField() is a function that returns the stack entry associated to the table ID and field ID.

Function Signature
getStackField(tableID: string, fieldID: string) : DrillDownItem;

getVariable()

The getVariable() is a function used on the Five object that will return values set from the setVariable() function.

Function Signature
getVariable(name: string) : any;

httpClient()

The httpClient() is a function that creates and returns a new HTTP client object.

Function Signature
httpClient() : HTTPClient;

isCloud()

The isCloud() is a function that returns whether the application is running in the cloud.

Function Signature
isCloud() : boolean;

isCreate()

The isCreate() is a function that returns true if the action is currently creating a record.

Function Signature
isCreate() : boolean;

isEdit()

The isEdit() is a function that returns true if the action is currently editing a record.

Function Signature
isEdit() : boolean;

isMobile()

The isMobile() is a function that returns true if the user interface is running in mobile mode.

Function Signature
isMobile() : boolean;

log()

The log() is a function that writes a message to Five's Inspector.

Function Signature
log(log: any) : void;

maxField()

The maxField() is a function that returns the maximum value from the array of records associated to the field ID.

Function Signature
maxField(records:Array<BasicRecord>, fieldID: string) : number;

minField()

The minField() is a function that returns the minimum value from the array of records associated to the field ID.

Function Signature
minField(records:Array<BasicRecord>, fieldID: string) : number;

now()

The now() is a function used on the five object that returns the current date and time in UTC as a string.

Function Signature
now(): string;

open()

The open() is a function that opens the supplied uri.

Function Signature
open(uri: string) : void;

refreshTable()

The refreshTable() is a function that refreshes any live queries associated to the table ID.

Function Signature
refreshTable(tableID: string) : void;

reload()

The reload() is a function that reloads the data on the current form.

Function Signature
reload() : void;

rollback()

The rollback() is a function that rollbacks a database transaction.

Function Signature
rollback(tx: Transaction) : FiveError;

selectFile()

The selectFile() is a function that opens a file opened dialog for a user to select a file.

Function Signature
selectFile(context: any, acceptedExtensions: Array<string>) : FiveError;

selectMenu()

The selectMenu() is a function that selects a menu and opens the record specified by the record keys.

Function Signature
selectMenu(menuID: string, ...recordKeys: Array<string>) : void;

sender()

The sender() is a function that returns the sender associated with the event callback.

Function Signature
sender() : any;

sendNotification()

The sendNotification() is a function that sends a notification to the client, where it will display in the UI.

Function Signature
sendNotification(userKey: string, notification: string) : void;

setVariable()

The setVariable() is a function used on the Five object that sets a global variable.

Function Signature
setVariable(name: string, value: any) : void;

showError()

The showError() is a function that shows an error dialog with the supplied message.

Function Signature
showError(message: string) : void;

showMessage()

The showMessage() is a function that is used to display a message to the client that will be displayed in the UI.

Function Signature
showMessage(message: string) : void;

startTransaction()

The startTransaction() is a function that starts a transaction with a database connection.

Function Signature
startTransaction(db: DatabaseConnection) : FiveError;

success()

The success() is a function that returns a FiveError object indicating success.

Function Signature
success([currentResult: FiveError | message: string, [message: string, [notification: string]]]) : FiveError;

sumField()

The sumField() is a function that returns the sum of all the values from the array of records associated to the field ID.

Function Signature
sumField(records:Array<BasicRecord>, fieldName: string) : number;

time()

The time() is a function used on the five object that returns the current local time as a string.

Function Signature
time(): string;

uuid()

The uuid() is a function that returns a unique identifier.

Function Signature
uuid() : string;