Triggers: Difference between revisions

87 bytes added ,  22 September 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 105: Line 105:


==== entry() ====  
==== entry() ====  
: Get the entry in the context of which the script is being executed. For example, if script is triggered by an Update Entry event, this method will return the entry being updated.
: Get the entry of the Event. For example, if script is triggered by an Update Entry event, this method will return the entry being updated.
   
   
: This function is available to all actions and phases, with the exception of "Creating a file — opening Entry Edit card for add"; for this action, use the method entryDefault().
: This method is available to all Events and Phases, with the exception of "Creating a file > Opening an Entry Edit card for add"; for this action, use the method entryDefault().


: Result: Object Entry, the current entry
:; Result: Entry object — the current entry


==== entryDefault() ====  
==== entryDefault() ====  
: Get the Entry object containing the default values for the Entry not yet created. This feature is available for the ''Open card'' phase of the action ''Creating an entry''.
: Get the Entry object containing the default field values for the Entry not yet created. This feature is available for the Event ''Creating an entry > Opening an Entry Edit card''.


:Result: The object DefaultEntry.
:; Result: The DefaultEntry object


==== lib() ====  
==== lib() ====  
: Get the library in the context of which the script is being executed.
: Get the library of the Event


: Result: Object Library, the current library
:; Result: Library object — the current library


==== libByName(name) ====  
==== libByName(name) ====  
: Identify the library by name. Permission to use the library required.
: Get the named library. Permission to use the library is required.


:Result: Object Library, the library identified
:; Argument: The name of the library to get
 
:; Result: Library object — the library identified by the argument ''name''


=== Object ''Library'' ===
=== Object ''Library'' ===
This object provides access to library entries. You can work with the current library — the lib() or any other library database — libByName(). This method provides the ability to update existing entries and create new ones.
This object provides access to library entries. You can work with the current library — the lib() — or any other library database — libByName(). This method provides the ability to update existing entries and create new ones.


==== Methods ====
==== Methods ====
===== entries() =====
===== entries() =====
: Get all the entries of the library.
: Get all the entries of the library
:; Result: array of entries, sorted by time of their creation, from newest to oldest
:; Result: array object containing entries, sorted by the time of their creation, from newest to oldest


===== find(query) =====
===== find(query) =====
: Search for entries in the library matching given field values. This search is similar to searching via Memento's user interface.
: Search for entries in the library matching given query, which are field values. This search is similar to searching via Memento's user interface.
:; Parameters: query — the search string
:; Argument: query — the search string
:; Result: Array of matching entries. Entries are sorted by time of their creation, from newest to oldest.
:; Result: Array object containing matching entries. Entries are sorted by the time of their creation, from newest to oldest.


===== findByKey(name) =====
===== findByKey(name) =====
: Search for all entries by the Entry Name field value. The library must be enabled for unique names.
: Search for all entries by the Entry Name field value. The library must be set for unique Entry Names.
:; Parameters: name — the Entry Name field value
:; Argument: name — the Entry Name field value
:; Result: Object Entry
:; Result: Entry object


===== create(values) =====
===== create(values) =====
: Create a new entry in the library.
: Create a new entry in the library
:; Parameters: [https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object '''Object'''] containing the field values
:; Argument: [https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object '''Object'''] containing the field values
:; Result: Object Entry, the new entry in the library
:; Result: Entry object — the new entry in the library


==== Properties ====
==== Properties ====
; Title : The name of the library
; Title : The name of the library
 
-----
=== Object ''Entry'' ===
=== Object ''Entry'' ===
This place is a record library and provides the ability to get and set field values.
This place is a record library and provides the ability to get and set field values.