New to Javascript and Automation - looking for help and understanding

157 views
Skip to first unread message

Alex MacKenzie

unread,
May 20, 2025, 2:52:39 PM5/20/25
to mementodatabase
Hey All,

Very simple auto complete automation rule I'm trying to right. 

I have two fields. A mutli select and a date field.

I want the date filed to automatically fill with current date when the multiselect field =="Complete".

I set up many of these rules throughout my library as I track many different items. Problem is, any time I'm editing the fields its overwriting my dates. Before I realized what was happening I ended up overwriting several weeks worth of data collection in a single afternoon :(

I believe I've figured out how to tell the rule not run based on multiple conditions..

Demising Framing is the multi select field
Demising Framing Complete is a date field that I fill out once the work has been completed.

My question is this, when I build this using the Autmation tool I don't see this snippet "entry().setById('R0FONTxNeiN5WGUqQEFNS25bIzM'"... Where I'd doing about 30 pairs of fields I'd prefer to script it and not build it through the automation tools.

Can someone explain where / how to get the ":entry().setById('R0FONTxNeiN5WGUqQEFNS25bIzM'" for each field in memento? 



"// Demising
{
if (entry().obtain('Demising Framing')=="Complete" && entry().obtain('Demising Framing Complete')=="") {
entry().setById('R0FONTxNeiN5WGUqQEFNS25bIzM', entry().obtain('_modified'));
}}"

Er Mo

unread,
May 20, 2025, 3:04:53 PM5/20/25
to mementodatabase
Hallo
Das " entry().setById() " heißt so viel " Setze für den Eintrag mit der Identifizirung " . Es beschreib den Eintrag in den Geschriben werden soll

Hello
The "entry().setById()" function essentially means "set for the entry with the identifier." It describes the entry to be written to.

Ernst

Mmm

unread,
May 21, 2025, 3:22:49 AM5/21/25
to mementodatabase
Можете использовать встроенные фильтры для создания условий правила. 
Шаблон с примером во вложении. 

вторник, 20 мая 2025 г. в 22:04:53 UTC+3, ernst...@gmail.com:
IC_21052025.jpg
rule_test.mlt2

Bill Crews

unread,
May 21, 2025, 8:05:41 AM5/21/25
to Er Mo, mementodatabase
In the wiki > Scripting > Memento JavaScript Library, the Entry object shows only the following methods...
  • field()
  • images()
  • link()
  • recalc()
  • set()
  • show()
  • trash()
  • unlink()
  • untrash()
The DefaultEntry object shows only...
  • set()
If there are others, like setById(), someone who knows about it should add the missing methods to the wiki. Otherwise, how are people supposed to know of them and how to use them?


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mementodatabase/29eb8715-833f-4fba-890d-1281ef033312n%40googlegroups.com.

Mmm

unread,
May 21, 2025, 1:55:32 PM5/21/25
to mementodatabase
Предположу, что entry().setById() усовершенствованный аналог entry().set().
Разрабатывая правила автоматизации, автору необходимо было избавиться от имен полей. 
При наличии нескольких одноименных полей или заголовков скрипты обращаются к полю (подзаголовку) с наименьшим индексом. И это не всегда верно. 
Если обращаться к полю по его ID, то всегда можно обратиться к нужному полю.

Вероятно, в дальнейших разработках автор предоставит больше возможностей для Пользователей и задокументирует метод.
В качестве примера. Уже существуют: имя и ID библиотек, имя и ID записей, имена полей есть - ожидаем ID полей ( field().id ).

Самый простой способ получить ID поля в настоящее время следующий:
1. Создать правило без условий.
2. Добавить задачу "Обновить поле" с выбором нужного поля без указания значения.
3. Сохранить правило и преобразовать в скрипт.
4. В итоге становится известным ID нужного поля.
5. Метод entry().setById(id, value) корректно работает в обычных скриптах даже при наличии одноименных полей (подзаголовков) в библиотеке. Уже сейчас это можно использовать при одноименных подзаголовке и поля в нем.

Более точную информацию может дать только автор (разработчик).

среда, 21 мая 2025 г. в 15:05:41 UTC+3, bill....@gmail.com:
Reply all
Reply to author
Forward
0 new messages