Acknowledge completion of script

414 views
Skip to first unread message

Simon Hall

unread,
Mar 31, 2025, 8:08:46 AM3/31/25
to mementodatabase
I have a couple of Scripts that end with

message(" Done! ");

However the message is quite short-lived so I frequently miss it.

Is it possible to replace this with a message that persists until I acknowledge it?

Thanks as always

Mmm

unread,
Mar 31, 2025, 9:24:00 AM3/31/25
to mementodatabase
1. В общие скрипты добавить функцию:

function msg(text,title) {
    var myDialog = dialog();
    myDialog.title(title || 'ℹ️ Info')
        .text(text ||  " Done! " )
        .positiveButton("Ok", () => {return true})
        .show();
}

2. Заменить:

message(" Done! ");

на 

msg(); 
//Если нужен другой текст и (или) заголовок 
//msg("Text","Title");

понедельник, 31 марта 2025 г. в 15:08:46 UTC+3, Simon Hall:

Simon Hall

unread,
Mar 31, 2025, 12:17:52 PM3/31/25
to mementodatabase
Thanks Mmm
Perfect as ever

Bill Crews

unread,
Apr 1, 2025, 6:44:12 AM4/1/25
to Mmm, mementodatabase
Now, THIS is what I call a TUF, or truly useful function and its code. NEARLY ALL Memento users who use JavaScript triggers, actions, or Button field scripts have wanted such a function, and MANY of us haven't delved into the Memento UI library (part of widgets & dashboards) yet, so we haven't yet got the "hang" of using it. 

This should go into some wiki examples pages in the Scripting section. 

I'd suggest considering use of this as "dipping your toe" into using the Memento UI JavaScript library, which would open the door to using widgets & dashboards, if you haven't yet.

Good work, Mmm. Sometimes, it's the little things that help the most. 


--
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/829dd3e8-459c-4d43-9a06-16f5a8e6f45an%40googlegroups.com.

Amundsf

unread,
Apr 2, 2025, 6:05:31 PM4/2/25
to mementodatabase
This is good :-)

Mmm: Is it a way to stop saving of record when using Dialog?

I do some validation like this:
if (type == 'Cost' && amount > 0 ) {
message("Amount must be negative for costs");
cancel();
exit();
}

When this occour user get noticed and the save of entry stops. User have to change to valid data and save will then be OK.

A week ago I had another kind of validation that I wanted to do where I want user to select IF the data is ok or not. So I tried the Dialog for the first time.

The problem is that this code parts stops the save for all three buttons:
if (invoicedInErp == 1 ) { 
const myDialog = dialog()
myDialog.title("Invoiced in ERP activated")
.text("Is this correct?")
.positiveButton("Yes", (DialogOk(e)) )
.negativeButton("No", (cancel()) )
.neutralButton("Cancel", (cancel()) )
.show();
}
}

function DialogOk(e){
// What to do to make save of entry continue?
}


Is it possible to make it save?
Based on what Ernst write in this post I have a feeling that it's maybe not possible today? If I'm wrong I will be verry happy 😄

(For know I have worked around it with a Yes/No field that user can select to allow save. But it would be a much better solution if Dialog was working for this).

Thank you in advance 
 - Amund

Amundsf

unread,
Apr 2, 2025, 6:09:34 PM4/2/25
to mementodatabase
Second quetion:
This function from Mmm above is so good that I guess it will be relevant to use it in several libraries.
I have a feeling that I have seen something about making functions commonly available for all libraries. Can someone point me in the direction of how to do that? :-)


Thank you in advance
 - Amund

Mmm

unread,
Apr 3, 2025, 3:24:06 AM4/3/25
to mementodatabase
1. Окна dialog() не останавливают выполнение триггеров.

2. Доступ к скриптам из разных библиотек – персональный репозитарий...
https://groups.google.com/g/mementodatabase/c/nCPXd3d3qtE/m/lyCdDIeYCgAJ

четверг, 3 апреля 2025 г. в 01:09:34 UTC+3, Amundsf:

Er Mo

unread,
Apr 3, 2025, 2:23:34 PM4/3/25
to mementodatabase
Hallo
Zu 1 : Schreibe die Funktionen mal VOR den dialog() Teil . Also so das im Skripttext nach den aufruf von dialog() und dessen Ende nichts mehr steht .
zum Speichern : Im Skript " Vor den Speichern " wird dialog() aufgerufen wenn das Kontrollfeld leer/ Nein ist und dann das Skript abgebrochen/ beendet . Das dialog() fraget das Speicher ab . Wenn " JA " füllt es das Kontrollfeld aus/Ja . Wenn sich das Dialog() schließt kommt mann wider zum Eintrag dernoch nicht gespeichert ist . Klickt man jetzt auf Speichern wird das dialog() nicht angezeigt und nicht Abgebrochen weil das Kontrolfeld auf JA steht . So wird der Eintrag gespeichert . Das Kontrollfeld kann man Unsichtbar machen .
Zu 2 : Mann kann JS Dateien von Internet in Memento einbinden . Den Skript text schreiben und als Text Datei speichern . Diese mit der Endung " js "versehen . Die Datei im Indernet speichern . Im Skripteditor lassen sich JaveSkript-Bibliotheken hinzufügen .Da URL Hinzufügen auswählen und die URL Eingeben ( http://............ Datei.js ) . Die muss für jedes Skript gemacht werden das auf das Internet Skript zugreifen soll .

Hello
Regarding 1: Write the functions BEFORE the dialog() part. So that there's nothing left in the script text after the dialog() call and its end.
Regarding saving: In the script "Before saving," dialog() is called if the checkbox is empty/No, and then the script is aborted/terminated. Dialog() queries the memory. If "YES," it fills in the checkbox/Yes. When Dialog() closes, you return to the entry that hasn't been saved yet. If you now click Save, dialog() won't be displayed and won't be aborted because the checkbox is set to YES. This way, the entry will be saved. The checkbox can be made invisible.
Regarding 2: You can embed JS files from the internet in Memento. Write the script text and save it as a text file. Give it the extension ".js." Save the file on the internet. JavaScript libraries can be added in the script editor. Select "Add URL" and enter the URL (http://............ file.js). This must be done for each script that should access the internet script.

Ernst

Amundsf

unread,
Apr 3, 2025, 2:52:15 PM4/3/25
to mementodatabase
Hi

Ernst wrote:
Dialog() queries the memory. If "YES," it fills in the checkbox/Yes. When Dialog() closes, you return to the entry that hasn't been saved yet. If you now click Save, dialog() won't be displayed and won't be aborted because the checkbox is set to YES. This way, the entry will be saved.

Yes, it's something like that I have to do. My hope was that the code could set the checkbox to Yes if user answered Yes, but I understand that it's not possible.


Regarding 2:
The file must be saved on internet? Any suggestions where to store it, must I have a file server or something?

Thank you a lot 
 - Amund

Amundsf

unread,
Apr 3, 2025, 2:59:44 PM4/3/25
to mementodatabase
Mmm:
I have tried to implement this now:
function msg(text,title) {
    var myDialog = dialog();
    myDialog.title(title || 'ℹ️ Info')
        .text(text ||  " Done! " )
        .positiveButton("Ok", () => {return true})
        .show();
}

I'm using it on a trigger to display end message to user (that last longer than a message() ).
On desktop it's working fine, but on android it dissapear almost at once. Is just as it is designed for trigger?

 - Amund

Amundsf

unread,
Apr 3, 2025, 3:10:58 PM4/3/25
to mementodatabase
I read once more from you Ernst regarding 1:
Dialog() queries the memory. If "YES," it fills in the checkbox/Yes. 

This what I have tried to do, but it don't work. Checkbox isn't updated when selecting Yes in the Dialog.
I was guessing that because entry is closed it's not possible to do changes any more? Am i wrong - is it me that do something wrong?

Amund


Er Mo

unread,
Apr 3, 2025, 3:55:10 PM4/3/25
to mementodatabase
Hallo

Bei mir geht es . Hier ein Test zum Speichern . Ändert das Kästchen " Eingetragen " wenn das Aktions Skript " Speichern " Ausgefürt wird . Damit man es sieht , die Bibliothek verlassen und neu öffnen .

Hello

It works for me. Here's a test for saving. Change the "Entered" checkbox when the "Save" action script is executed. To see it, exit the library and reopen it.


Ernst

Amund Stigen Fjeld

unread,
Apr 6, 2025, 5:07:14 PM4/6/25
to Er Mo, mementodatabase

Hi again

I have tried to test you library Ernst. 

I copied the library to see structure and scripts. I never experience schalt2 to change the value of Eingetragen. I can push OK how many times I will: The value is not changed and the save is never done (since the field isn't changed). I have tested for both new record and edit (activated script for change).


At least when I try your library the Dialog message is visible and stays to I push a button. For all my libraries (i have testet 3-4 different) the Dialog just flash a verry short time and dissapears. I tried to create a new test library now with this script below for trigger new entry phase before save:

dbox('Test');

function dbox (te){
const myd=dialog()
myd.title( "Title")
myd.text(te)
myd.positiveButton("OK",() =>{})
myd.negativeButton("Abbruch",()=> {})
myd.show();
return
}

function funcOK(){
return
}

It just flash before it's gone. What can it be that do that? 


Thank you all a lot for any new suggestions 🙂


Thank you in advance 

Amund 



You received this message because you are subscribed to a topic in the Google Groups "mementodatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mementodatabase/QKZQ1YF8wXM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mementodataba...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mementodatabase/01dda4b7-a978-44a8-b2fe-4a3b638a8542n%40googlegroups.com.

Amund Stigen Fjeld

unread,
Apr 6, 2025, 5:09:17 PM4/6/25
to Er Mo, mementodatabase
The message above is for Memento version 5.5.3 on Android.

Mmm

unread,
Apr 7, 2025, 6:32:42 AM4/7/25
to mementodatabase
Выше уже упоминал, что окно dialog() не останавливает выполнение триггера. 
Поэтому Эрнст использует программное прерывание скрипта после вызова окна. 

dbox('Test');
cancel();

Тестовая библиотека Эрнста работает для триггера создание записи перед сохранением. 
Принцип основан на полном запрете создания записи стандартным способом. 
Вместо видимой записи создаётся её копия после подтверждения OK. 

Этот приём не подходит для триггеров изменение записи и изменение поля. 

Проверьте название своей библиотеки, в скрипте используется libByName() вместо lib(). 
Кроме того, проверьте какая функция вызывается при подтверждении OK. 

Если добавить поле с уникальным значением или использовать для этого имеющееся поле (например, "Ganzzahl"), то можно предотвратить создание нескольких копий записей в случае неоднократного подтверждения OK. 

Уникальность можно проверить с помощью стандартного инструмента контроля или с программно, например с помощью some(). 

понедельник, 7 апреля 2025 г. в 00:09:17 UTC+3, Amundsf:

Er Mo

unread,
Apr 7, 2025, 2:05:10 PM4/7/25
to mementodatabase
Hallo Amund
In Meiner Struktur der Skripte habe ich jede funktion in ein eigenes Skript geschriben . So Endet dieses auch nach den Ablaufen . Wenn du mehrere Funktionen in ein Skript schreibst können diesen nach einnander durchlaufen werden OHNE die Funktion aufzurufen . Schreibe den Aufruf der alles Startet als letztes in den Skript .  Der Wert in " Eingetragen " wird geändert , aber NICHT angezeigt . Du musst die Bibliothek verlassen und erneut den Eintrag aufrufen . Dann wird es sichtbar

Hello Amund
In my script structure, I've written each function into its own script. This way, it ends after it has run. If you write multiple functions in a script, they can be executed one after the other WITHOUT calling the function. Write the call that starts everything last in the script. The value in "Entered" will be changed, but NOT displayed. You have to exit the library and call the entry again. Then it will be visible.

Ernst

Amundsf

unread,
Apr 9, 2025, 11:58:38 AM4/9/25
to mementodatabase
Hi again

Again: Thank you so much both of you much for your help, both of you :-)

I'm starting to get it to work, but I have two more questions to fully understand it.

First my code - this is the last part of my function validate():
var invoiceInERP = e.field('Fakturert i ERP');
var dialogDisplayed = e.field('DialogSaveOk')
if ( invoiceInERP   == 1 && dialogDisplayed == 0) {

const myDialog = dialog()
myDialog.title("Fakturert i ERP er aktivert")
.text("Fakturert i ERP betyr at betalingen ikke vil komme med i bilagseksport til ERP. Er dette riktig? \n\nHvis det er riktig kryss for dette på Systemsiden")
.positiveButton("OK", () => {DialogOk(e) } )
//.negativeButton("Nei", () => {} )
.show();

cancel();
exit();


}

}

function DialogOk(e){
//message("DialogOK");
e.set(' DialogSaveOk  ', true);
cancel();
exit();

}


1. Placement of cancel() and exit()
I thought that all code was stopped when using cancel() AND exit(); 
Is that wrong? Is it just the code in the function it self that is stopped and not functions calling the sub function? It makes sence based on other languages I have used, but haven't experinced it like that for other scripts in Memento.

When I just have those two in function DialogOk() (red) the message just flash a short time.
When I have them right after Dialog() the message stays.

2. Update field on entry
I see that you are right Ernst the update of DialogSaveOk is visible when changing entry. But that kind of don't help me.

Actually, that it's not visible isn't bothering me, but if it should work it should work like this after the Dialog is show'ed:
1. User click positive button => DialogSaveOk = true
2. User click save another time
Script get's true for: var dialogDisplayed = e.field('DialogSaveOk')
3. Dialog is not displayd.

This is not possible before user change to another entry and back?
If so I will remove this part, then I rather want the user to set the value manually.


Thank you again in advance 
 - Amund

Er Mo

unread,
Apr 9, 2025, 1:59:20 PM4/9/25
to mementodatabase
Hallo
Du brichst die Funktion "DialogOk(e) " ab und beendest diese . Du soltes die Funktion nicht abbrechen , sonder nur beenden . Also nur exit() ausfüren

Hello
You are aborting and exiting the function "DialogOk(e)". You shouldn't abort the function, just exit it. So, just execute exit().

Ernst

Mmm

unread,
Apr 9, 2025, 2:32:41 PM4/9/25
to mementodatabase
Опубликуйте полный код, а не куски из него. А лучше создайте и покажите тестовый вариант библиотеки.
Окно dialog() вызывается из триггера создания записи?


среда, 9 апреля 2025 г. в 20:59:20 UTC+3, ernst...@gmail.com:

Amundsf

unread,
Apr 11, 2025, 8:12:12 AM4/11/25
to mementodatabase
Hi

I have made a new test library for me to test on Dialog and I start to understand it :-)

Here is my test library: https://mementodb.com/s/0gCXoOV2F 

It almost work as I want:
When condisions is there Dialog is show'ed
And the entry stays.

But what don't work is:
1. User answer OK in Dialog
2. I want that when user Save again Dialog will not appear because field AllowErpSave is true.

Is it possible to acchieve?

Thank you in advance
 - Amund

Mmm

unread,
Apr 11, 2025, 1:18:36 PM4/11/25
to mementodatabase
Попробуйте перенести поле "AllowErpSave" в отдельную библиотеку "validate".

Добавьте 4 триггера для управления этим полем из библиотеки "Test3", которые будут присваивать  полю "AllowErpSave" значение false:
- создание записи открытие формы (1) и после сохранения (2),
- изменение записи открытие формы (3) и после сохранения (4).

Тестовые библиотеки:
https://mementodb.com/s/yPkaHxaET
https://mementodb.com/s/FiuKxSAv5

При необходимости контролировать несколько полей - добавить другие контрольные поля в библиотеку "validate".

Связь между библиотеками только для быстрого перехода между ними (можно удалить).

Вариант с дополнительной библиотекой позволяет контролировать любое количество полей для любого количества библиотек.
Запись с ID библиотеки создается автоматически при первом обращении.

Поиск соответствующей записи в библиотеке "validate" выполняется с помощью findByKey(name), поэтому имя записи должно быть включено как уникальное.

пятница, 11 апреля 2025 г. в 15:12:12 UTC+3, Amundsf:

Er Mo

unread,
Apr 12, 2025, 1:18:43 PM4/12/25
to mementodatabase
Hallo
Wir haben einen Großen Fehler im System . 1 Speicher --> Bedingung ist NICHT erfüllt --> dialog() wird angezeigt --> dialog() mit OK bestätigt --> 2 Speichern --> Bedingung ist NICHT erfüllt ???? . Weil der Eintrag mit der änderung NICHT gespeichert worden ist .
 Ich habe eine 2 Bibliothek (" rs " ) mit 1 Eintrag hinzugefügt der für nicht OK =0 und für OK =1 ist .Das dialog() Schaltet mit OK den Eintrag in der " rs " auf 1 . Wird der Eintrag gespeichert wird der Eintrag wieder auf 0 gestellt .
Hier die Bibliotheken

Hello
We have a major error in the system. 1. Save --> Condition is NOT met --> dialog() is displayed --> dialog() is confirmed with OK --> 2. Save --> Condition is NOT met ???? Because the entry with the change was NOT saved.
I added a 2nd library ("rs") with 1 entry that is 0 for not OK and 1 for OK. The dialog() sets the entry in the "rs" to 1 with OK. If the entry is saved, the entry is reset to 0.
Here are the libraries


Ernst

Bill Crews

unread,
Apr 14, 2025, 7:49:35 PM4/14/25
to Er Mo, mementodatabase
Yes, I agree with Ernst. Vasily has described it to me this way...

"...at first glance, this appears to be a known issue—possibly a bug or an undocumented feature. The problem lies in the fact that the dialog button handlers are triggered only after the main body of the script has been executed and all data has been saved. As a result, the cancel methods cannot influence the main save workflow, making their use ineffective in this context.

This imposes certain limitations on what can be done when dialog buttons are clicked—they must not be tied to the current trigger event. Hopefully, in the future, there will be a way to integrate the trigger workflow with dialog button handlers more seamlessly."

Maybe we can figure out how to work around this? 


Mmm

unread,
Apr 15, 2025, 6:14:41 AM4/15/25
to mementodatabase
Это может сделать только разработчик.

В качестве примера – окно предупреждения об удалении записи.
При отрицательном ответе Пользователя триггер удаление записи не выполняется. 
Это легко проверить добавив вызов message() в триггер удаления записи.

Предположу, что необходим новый тип скриптов – "Подтверждение".
Это скрипт, который выполняет проверку условия (условий) перед наступлением события триггера. Результат скрипта "Подтверждение" возможный вызов стандартного окна dialog() с двумя кнопками с помощью встроенной функцией showValid(title, text).

Пример скрипта (внимание, такой функции нет в Memento):

let e = entry();
let number = e.field("number");

if (number > 5) {
    showValid("Attention", "The number is greater than 5. Continue?");

Для всех триггеров (в первую очередь, которые имеют момент запуска "перед сохранением") добавить настройку "Запуск по условию" с выбором одного конкретного скрипта "Подтверждение".

В результате обсуждаемый в теме пример мог быть выполнен, как нужно автору вопроса.

Алгоритм:
1. Создать скрипт "Подтверждение". Задать заголовок и текст стандартного окна. 

2. В триггере создание записи перед сохранением включить "Запуск по условию" и выбрать скрипт из пункта 1. 

3. При наступлении события триггера сначала выполняется скрипт "Подтверждение". 
Триггер из пункта 2 запускается в определённых случаях: 
— условие не выполнено (окно не вызывалось), 
— условие выполнено и Пользователь подтвердил "Ok" в окне предупреждения. 
В других случаях выполнение триггера прерывается. 

Возможно в будущих версиях разработчик добавит этот или подобный функционал. 

вторник, 15 апреля 2025 г. в 02:49:35 UTC+3, bill....@gmail.com:

Bill Crews

unread,
Apr 15, 2025, 9:40:40 AM4/15/25
to Mmm, mementodatabase
The developer has received your suggestion, Mmm, and it sounds to me like that's the best we can do. No workaround for us and a suggestion for him. 

Unless anyone else has any workaround ideas, I guess this thread can finally be concluded. Thanks for this (I think) useful discussion.


Amund Stigen Fjeld

unread,
Apr 16, 2025, 8:26:36 PM4/16/25
to mementodatabase
Hi 

Thank you all for contributing get to the bottow of this 🙂

If we go back to the script Mmm posted in this thread's second post I still have one question: What is valid icon's I can use instead of i for information? Is there a list somewhere? 

I would want also icon for warning and error, maybe others. 

Thank you in advance
 - Amund

Reply all
Reply to author
Forward
0 new messages