Triggers: Difference between revisions

217 bytes added ,  22 September 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 3: Line 3:
'''''[[This page is incomplete, incorrect, in the midst of translation, and under development.]]'''''
'''''[[This page is incomplete, incorrect, in the midst of translation, and under development.]]'''''


A Trigger is a script that initiates certain actions or events. Trigger scripts are written in [https://developer.mozilla.org/en-US/docs/web/JavaScript JavaScript]. When a trigger script is executed, it may change an existing entry, create a new entry, execute an http request, create a file, perform data validation, etc.
A Trigger is a script that defines the processing of an entry based on the Event that took place. Trigger scripts are written in [https://developer.mozilla.org/en-US/docs/web/JavaScript JavaScript]. When a trigger script is executed, it may change an existing entry, create a new entry, execute an http request, create a file, perform data validation, etc.
 
=== Terminology ===
So, we define the following terms:
:; Event type
:: One of the following:
::* Creating an entry
::* Updating an entry
::* Deleting an entry
::* Opening an Entry Edit card
::* Adding an entry to Favorites
::* Removing an entry from Favorites
 
:; Event
:: One of a predefined set of moments (Event type & Phase) during entry processing during which the user can intervene via a trigger script. See the table of events below.
 
:; Trigger
:: A script that may be defined to run when an event occurs for an entry


== Creating a trigger ==
== Creating a trigger ==
Each library can have a number of triggers — up to one for each Action type. To see the list of triggers, open the library, open the menu, and then select ''Triggers''.
Each library can have a number of triggers — up to one for each Event. To see the list of triggers, open the library, open the menu, and then select ''Triggers''.
 
To create a trigger, open the library's list of triggers and click <big>'''+'''</big>. You must then identify the Action type and write a trigger script that performs the necessary action.


== Event that initiates execution of the trigger ==
To create a trigger, open the library's list of triggers and click <big>'''+'''</big>. You must then identify the Event and write a trigger script that performs the necessary actions.
The launch of the trigger is defined by two parameters:
; Action
: is any action performed by the user on an entry
; Phase of an action
: a subdivision, or specific step, of an action. A trigger can be fired during a phase of an action. Each action type can have a different set of phases.


=== Script execution ===
== Mode of script execution ==
The phase that activates the trigger also defines how the trigger will be executed &mdash; synchronously or asynchronously.
The phase in which the trigger is activated defines its mode of execution &mdash; synchronous or asynchronous.


; Synchronous script execution
; Synchronous script execution mode
: implies the application suspends user interaction and executes the script. It is not recommended to perform time-consuming operations in this case.
: implies the application suspends user interaction and then executes the script. It is not recommended to perform time-consuming operations in this case.


; Asynchronous script execution
; Asynchronous script execution mode
: results in the script running in the background; user interaction is not suspended. Usually, asynchronous scripts are used in the last phases of the action.
: results in the script running in the background; user interaction is not suspended. Usually, asynchronous scripts are used in the last phases of the action.


Line 51: Line 61:
|+ THE DEFINED ACTION TYPES
|+ THE DEFINED ACTION TYPES
|-
|-
! Action type !! Phase !! Execution type
! Action type !! Phase !! Execution mode
|-
|-
| rowspan="3" | '''Creating an entry'''
| rowspan="3" | '''Creating an entry'''