Namespace: context

context

The main API for interacting with the app.

Methods

alert(opts)

Shows an alert dialog to the user.
Parameters:
Name Type Description
opts Object Optional object for configuring the alert.
Properties
Name Type Description
message String The alert message.
ok function Callback function when the dialog is closed.

back()

Goes back to the previous view.

closeDialog(data)

Closes the current dialog.
Parameters:
Name Type Description
data Object Optional data to pass back.

confirm(opts)

Shows a Yes/No confirmation dialog to the user.
Parameters:
Name Type Description
opts Object Configuration object.
Properties
Name Type Description
message String The message to display in the dialog
title String The message to title in the dialog
ok function Callback function when the user presses 'OK'
cancel function Callback function when the user closes the dialog without pressing OK.

continueTo(nextView)

Changes the currently shown view. Uses existing form data as the data for the new view.
Parameters:
Name Type Description
nextView String The id of the next view.

create(record, opts)

Create a record in the database
Parameters:
Name Type Description
record Record to create
opts Object Options
Properties
Name Type Description
onSuccess function Callback function for success
onError function Callback function for error

createRecord(modelName, data) → {Record}

Creates a record-object
Parameters:
Name Type Description
modelName String Name of model to create record of
data Object Data for record-attributes and related records.
Returns:
Type
Record

createTemplateContext(opts) → {TemplateContext}

Creates a template context using the specified data and records.
Parameters:
Name Type Description
opts Object Optional configuration object
Properties
Name Type Description
data Object -
records Array -
Returns:
- The created context.
Type
TemplateContext

createWidget(opts)

Creates a new widget using the specified data.
Parameters:
Name Type Description
opts Object Configuration object.
Properties
Name Type Description
attachPoint Object The point to attach the widget to (optional).
parent Object A parent widget (optional).
widget Object The widget data.
onSuccess function Callback when the creation was finished successfully.
onError function Callback when the creation resulted in an error.

createWindow(opts)

Creates a HTML dialog window.
Parameters:
Name Type Description
opts Object Configuration object.
Properties
Name Type Description
url String
content String
template String
data Object
records Array

delete(record, opts)

Delete a record in the database
Parameters:
Name Type Description
record Record to delete
opts Object Options
Properties
Name Type Description
onSuccess function Callback function for success
onError function Callback function for error

dial(number)

Dial a phone-number
Parameters:
Name Type Description
number String The phone number to dial.

downloadVirtualFile(opts)

Creates and downloads a virtual file using the provided data.
Parameters:
Name Type Description
opts Object Configuration object
Properties
Name Type Description
data Object The file data
fileType String The file type
fileName String The filename

executeTemplate(opts) → {String}

Compiles a template string.
Parameters:
Name Type Description
opts Object Configuration object
Properties
Name Type Description
template String The template name
Returns:
- The compiled template.
Type
String

getConfigParam(name) → {ConfigurationParameter}

Returns a configuration parameter using the specified name, or null if no such parameter exists.
Parameters:
Name Type Description
name String The name of the parameter.
Returns:
Type
ConfigurationParameter

getData(name) → {Object}

Returns previously stored clientside data.
Parameters:
Name Type Description
name String The identifier used when storing the data.
Returns:
- The data, or null if none was found.
Type
Object

getDateFunctions() → {DateFunctions}

Gets the Date-API
Returns:
Type
DateFunctions

getForm(formId) → {Form}

Fetches a form from the current view using the provided form id.
Parameters:
Name Type Description
formId String The id of the form to return.
Returns:
- The form, or null if no form was found.
Type
Form

getGeneralFunctions() → {GeneralFunctions}

Gets the General API
Returns:
Type
GeneralFunctions

getGeoLocation() → {GeoFunctions}

Gets the Geo API
Returns:
Type
GeoFunctions

getMessageBus() → {MessageBus}

Gets the messagebus
Returns:
Type
MessageBus

getNumericFunctions() → {NumericFunctions}

Gets the Numeric API
Returns:
Type
NumericFunctions

getOrganization() → {Object}

Returns the current organization
Returns:
Type
Object

getParameter(name) → {QueryParameter}

Returns a query parameter using the specified name. Returns null if no query is present, or undefined the query exists but does not have the specified parameter.
Parameters:
Name Type Description
name String The name of the parameter.
Returns:
Type
QueryParameter

getPdf(opts)

Generates and downloads a pdf file
Parameters:
Name Type Description
opts Object Options
Properties
Name Type Description
onSuccess function Callback function for success
onError function Callback function for error

getPlugin(plugin)

Gets the API of a plugin.
Parameters:
Name Type Description
plugin String The name of the plugin to get.

getPrivilegesFor(record, opts)

Get all privileges for a certain record
Parameters:
Name Type Description
record Record to get privileges for
opts Object Options
Properties
Name Type Description
onSuccess function Callback function for success
onError function Callback function for error

getQueryHandle(name) → {QueryHandle}

Returns a handle to a query.
Parameters:
Name Type Description
name String The name of the Query Handle.
Returns:
Type
QueryHandle

getString(name)

Returns the localization string of the given name.
Parameters:
Name Type Description
name String The name of the localization string.

getStrings() → {Array}

Returns an array of the app's localization strings.
Returns:
- An holding all of the app's strings.
Type
Array

getTemplate(id)

Returns the template with the specified id.
Parameters:
Name Type Description
id String | ID The desired template's id.

getTenantId() → {ID}

Returns the ID of the current user's tenant.
Returns:
Type
ID

getURI(url) → {String}

Returns the full URI of the specified URL.
Parameters:
Name Type Description
url String -
Returns:
- The full URI
Type
String

getUser() → {User}

Returns the current user.
Returns:
Type
User

getView() → {View}

Returns a reference to the current view.
Returns:
Type
View

getWidget(widgetId) → {Widget}

Fetches a widget from the current view using the provided widget id.
Parameters:
Name Type Description
widgetId String The widget id of the widget to return.
Returns:
- The widget, or null if no widget was found.
Type
Widget

hasFeature(name) → {Boolean}

Checks if the user has the specified feature enabled.
Parameters:
Name Type Description
name String The feature name
Returns:
- True if the user has the feature enabled, otherwise false.
Type
Boolean

hideSpinner()

Hides the loading indicator

invoke(funcName, args) → {Object}

Invokes a function defined on the current view.
Parameters:
Name Type Description
funcName String The name of the function.
args Array Array of arguments to the function.
Returns:
- The functions return value, if any.
Type
Object

invokeAction(opts) → {dojo.Deferred}

Invokes an action
Parameters:
Name Type Description
opts Object Object holding configurations for the invokation.
Properties
Name Type Description
action String The name of the action to invoke.
record Object The record to send to the action
data Object Arbitrary data to send to the action
Returns:
- A dojo deferred object (See the Dojo documentation.
Type
dojo.Deferred

invokePlatformService(service) → {dojo.Deferred}

Invokes a platform service
Parameters:
Name Type Description
service String The name of the platform service
Returns:
- A dojo deferred object (See the Dojo documentation.
Type
dojo.Deferred

invokeService(opts) → {dojo.Deferred}

Invokes a server-side REST rule.
Parameters:
Name Type Description
opts Object Object holding configurations for the invokation.
Properties
Name Type Description
service String The name of the rule to invoke.
parameters Object Object of query parameters and their values.
data Object Object containing data to send.
Returns:
- A dojo deferred object (See the Dojo documentation.
Type
dojo.Deferred

isLoggedIn() → {Boolean}

Checks whether the user is logged in or not. Note that this method returns a Promise that resolves to a boolean.
Returns:
Type
Boolean

isMobile() → {Boolean}

Boolean value that indicates whether the current user is using a mobile device.
Returns:
- True if the current user is on a mobile device, otherwise false.
Type
Boolean

isViewAccessible() → {Boolean}

Checks whether the user has the right to view the specified view.
Returns:
- True if the user is allowed to view the specified view, otherwise false.
Type
Boolean

log(The)

Logs a message to the console.
Parameters:
Name Type Description
The String message to log.

mailTo(email)

Creates and opens a mailto: link.
Parameters:
Name Type Description
email String The email adress to use for the link.

message(options)

Shows a message notification to the user.
Parameters:
Name Type Description
options Object Optional parameter for configuring the message.
Properties
Name Type Description
delay Number A delay in milliseconds before the message notification is closed.
message String The notification message.
dismissable Boolean Decides if the message is dismissable.

notify(options)

Shows a success/error notification to the user.
Parameters:
Name Type Description
options Object Contains the configuration for the notification.
Properties
Name Type Description
type string The type of notification to display. This value must be either 'success', 'error' or 'info'.
message string The notification message.
delay Number The time in seconds until the notification is automatically closed.

openDialog(dialog, data, opts)

Opens a dialog view.
Parameters:
Name Type Description
dialog String The id of the dialog view.
data Record An optional record that is used to populate form-connected widgets in the dialog.
opts Object An object allowing for additional configurations.
Properties
Name Type Description
onDone function Callback function when the dialog is closed.

playSound(name)

Plays the specified sound resource
Parameters:
Name Type Description
name String The name of the sound resource.

prompt(opts)

Shows a prompt dialog to the user. The prompt dialog prompts the user for some information.
Parameters:
Name Type Description
opts Object Configuration object.
Properties
Name Type Description
message String The message to display in the dialog.
value String Default value for the input field.
ok function Callback function when the user presses ok.
cancel function Callback function when the user closes the dialog without pressing ok.

renderString(template, data)

TODO
Parameters:
Name Type Description
template String | Object -
data Object -

replaceTerm(name, vars)

TODO
Parameters:
Name Type Description
name String -
vars Object -

scheduleTask(options) → {String}

Schedules a task to be performed in set intervals
Parameters:
Name Type Description
options Object Configuration object
Properties
Name Type Description
callback function The task to be performed.
cancel function Callback when the task is cancelled.
name String An identifier for the task.
interval Number The interval (in milliseconds) between each task run.
repeat Boolean Specifies whether the task should be repeated after its first run or not.
Returns:
- The id of the task. This is needed to stop the task.
Type
String

setData(name, value, scope)

Stores clientside data.
Parameters:
Name Type Description
name String An identifier for the data. Must be specified when loading the data again.
value Object The value to store.
scope "persistent" | "global" | "default" The availability scope of the data.

setView(view, data, query)

Changes the currently shown view.
Parameters:
Name Type Description
view String The ID of the new view.
data Object An optional record that is used to populate form-connected widgets in the new view.
query Query -

showSpinner()

Shows the loading indicator

unscheduleTask(tid)

Stops a scheduled task.
Parameters:
Name Type Description
tid String The id that was returned when scheduling the task.

update(record, opts)

Update a record in the database
Parameters:
Name Type Description
record Record to update
opts Object Options
Properties
Name Type Description
onSuccess function Callback function for success
onError function Callback function for error