Triggers: Difference between revisions

62 bytes added ,  6 October 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 139: Line 139:


===== findByKey(name) =====
===== findByKey(name) =====
: Search for all entries by the Entry Name field value. The library must be set for unique Entry Names.
: Search all entries by the Entry Name. The library must be set for unique Entry Names.
:; Argument: '''name''' — the Entry Name field value
:; Argument: '''name''' — the Entry Name field value
:; Result: Entry object
:; Result: Entry object
Line 150: Line 150:
==== Properties ====
==== Properties ====
: '''Title''' — The name of the library
: '''Title''' — The name of the library
-----


=== Object ''Entry'' ===
=== Object ''Entry'' ===
This object holds an entry of the current library, primarily including field values. Methods provide access to the field values.
This object holds an entry of the current library, allowing the setting of field values


==== Entry Methods ====
==== Entry Methods ====
===== set(name, value) =====
===== set(name, value) =====
: Set the value of the named field. After being called once, there is an entry with values in the library.
: Set the value of the named field. Calling this method results in immediate writing of the value to the library.


:; Arguments
:; Arguments
Line 166: Line 165:
: Get the value of the named field
: Get the value of the named field
:; Argument: '''name''' — name of the field
:; Argument: '''name''' — name of the field
:; Result: The value of the field
:; Result: The value of the field. The type of the result depends on the type of the field.


==== Entry Properties ====
==== Entry Properties ====
: '''Title''' — account name
: '''Title''' — entry name
: '''Description''' — description
: '''Description''' — entry description
: '''Favorites''' — true, if the entry is in Favorites
: '''Favorites''' — true, if the entry is in Favorites
: '''Deleted''' — true, if the record is deleted (it is in the basket)
: '''Deleted''' — true, if the record is deleted (it is in the Recycle Bin)


=== Object DefaultEntry ===
=== Object DefaultEntry ===
Template with default values for a new record
Template with default values for a new entry


==== Methods ====
==== Methods ====
Line 188: Line 187:


==== Data Validation ====
==== Data Validation ====
Using scripts, you can check the correctness of input data. For example, for a field integer values ​​are allowed only from 0 to 200.
Using scripts, you can check the correctness of input data. For example, perhaps a field integer values ​​are allowed only from 0 to 200.


<source lang="javascript" line>
<source lang="javascript" line>
var num = entry().field("Number")
var num = entry().field("Number") // Get the value of field Number
if (num < 0 || num > 200) {
if (num < 0 || num > 200) {       // Test for value matching allowable range
  message("Wrong range");
  message("Wrong range");         // If the value is outside the range, display message "Wrong range"
  cancel();
  cancel();                       // Cancel the operation
}
}
</source>
</source>


# We get the value of the field Number
This script should be used for the Event '''Create entry''' or '''Update entry''' in the Before Saving phase.
# Tests for values ​​matching the allowable range
# If the value is out of range then display a message Wrong range
# Cancels the operation
 
This script should be used for the action '''Create entry''' or '''Change entry'''.


==== Set default values ====
==== Set default values ====