I need to send an email when multiple records are added. Is this possible?

[LEFT][SIZE=16px]Hello[/SIZE][/LEFT]

[LEFT][SIZE=16px]I have created a form application (editable grid type), and I need to send an email to a user when in this form one or more records are added.[/SIZE][/LEFT]

[LEFT][SIZE=16px]I can send the email every time a record is added, but what I need is for it to be sent until all the records are finished.[/SIZE][/LEFT]
[LEFT][SIZE=16px]Hello[/SIZE][/LEFT]

[LEFT][SIZE=16px]I have created a form application (editable grid), and I need to send an email to a specific user when one or more records are added.[/SIZE][/LEFT]

[LEFT][SIZE=16px]I can send mail every time a record is added, but I need to send the email until the user finishes adding all the records he needs. [/SIZE][/LEFT][LEFT][SIZE=16px]Is it possible to do this? If so, can you share an example of how to do it?[/SIZE][/LEFT]
[INDENT][LEFT][SIZE=16px]This is what I need to solve:[/SIZE][/LEFT]

[LEFT][SIZE=16px]The form allows registering access rights that are assigned to a user to perform certain tasks with some documents. [/SIZE][/LEFT][LEFT][SIZE=16px]When adding rights the application must send an email to the administrator indicating that rights have been added and that it is necessary for him to authorize these rights.[/SIZE][/LEFT]

[LEFT][SIZE=16px]I could send an email for each new access, but if 50 new rights are added, the administrator would receive 50 emails, which is not logical or practical. [/SIZE][/LEFT]

[LEFT][SIZE=16px]Therefore, I need the administrator to receive a single email indicating that a certain number of new records have been added.[/SIZE][/LEFT][/INDENT]

[LEFT][SIZE=16px]Can someone help me with ideas on how to solve this in scriptcase?[/SIZE][/LEFT]

[LEFT][SIZE=16px]There is no onClose or onExit event or something similar that allows me to execute code when the user closes the application. [/SIZE][/LEFT][LEFT][SIZE=16px]Any idea how I can do this?[/SIZE][/LEFT]

[LEFT][SIZE=16px]Thank you very much in advance for the help.

Aldo,[/SIZE][/LEFT]

Not sure you need this or this will help you or not. I have not been able to figure out how to send emails yet.

scAfterInsertAll.docx (117 KB)

You can create a global variable that counts the number inserts. In the onafterupdate event you add one to the counter. Depending on the count you send an email. Something like that?

Hi

Sorry for the late response.

Now, at what exact moment does Scriptcase consider that all records have been inserted, if onAfterInsertAll is used, When the usert leave the details of the form? After a certain period of inactivity? When exactly does the event occur?

I need the event to occur when the user leaves the application and returns to the menu. At that precise moment is when I need to send the email to the administrator.

If I use a global variable, this implies that a routine that repeats constantly must validate the value of the global variable outside of the application. Where should I insert that code that validates the global variable? In the project menu? Could you help me with an example that can guide me?

Thanks for all the help.