Triggers: Difference between revisions

659 bytes removed ,  19 September 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 183: Line 183:
If the standard tools can not be set to the desired value of the field by default, it can be done through a script.
If the standard tools can not be set to the desired value of the field by default, it can be done through a script.


===== Предыдущее значение из другого поля =====
===== Previous value of another field =====
Есть библиотека содержащая записи о дневном пробег автомобиля, велосипеда или ваших прогулках. В библиотеки есть поле StartingMileage и Mileage. При создании записи требуется в поле StartMileage заносить данные из поля Mileage предыдущей записи.
There is a library containing the records of the daily running of the car, bicycle or your walks. The library has StartingMileage field and Mileage.When you create a record is required in the field StartMileage enter data from the field Mileage previous record.
 
<source lang="javascript" line>
<source lang="javascript" line>
var entries = lib().entries();
var entries = lib().entries();
Line 192: Line 193:
}  
}  
</source>
</source>
#Получаем текущую библиотеку lib() и список её записей entries()
 
#Проверяем, что список записей не пустой, иначе прекращаем выполнение скрипта, так как у нас нет предыдущей записи
# Get the current library the lib () and a list of entries it records ().
#Список записей отсортирован от новых к старым, соответственно предыдущая запись находится в начале списка с индексом 0. Получаем значение поля Mileage из предыдущей записи.
# Check that the list is not empty entries, otherwise stop the script, so we do not have a previous record.
#Устанавливаем значение поля Mileage из предыдущей записи как значение по умолчанию для поля StartMileage.
# Records list is sorted from newest to oldest, respectively, the previous record is at the beginning of the list with an index value of 0. Get the Mileage field from the previous record.
Скрипт должен быть установлен для действия Создание записи и фазы Открытие формы.
# We set the value of the field Mileage from the previous record as the default value for the field StartMileage.


=====Начало следующего дня=====
=====Начало следующего дня=====