Hi everyone,
I need your advice on how to send an email notification based on a column value in an editable Data Grid. Here’s the scenario:
We have a column called Release Date, where users can enter a date via the Data Grid. This date is saved, and we want to send an email notification to the relevant person in the same row when the Release Date is exactly 28 days away. The email should notify them that the release date is approaching.
Questions:
How should I implement the logic to send the email? Should I use an If Else condition in a Server Action that handles email notifications? If yes, how should the condition to check whether the Release Date is 28 days from today be formulated?
Since this condition needs to be checked daily, would a Timer be the correct approach to schedule the Server Action to run every day? If so, can you provide tips on how to set a Timer to iterate through the records and only notify the concerned person if the condition is met?
I’ve added an example OML file for reference, and I’d appreciate any helpful tips or suggestions on how to handle this use case effectively. Thank you in advance for your guidance!
Hi,
You can handle this directly in a Server Action by using an Aggregate to retrieve all records that meet your condition. Set the Aggregate filter to:
Data.ReleaseDate = AddDays(CurrDate(), 28)
Then, loop through the results with a ForEach and send the email for each record.
To automate it, configure a Timer to call this Server Action on a daily schedule.
I’ve attached the updated OML with the implementation.
Hi Mihai,
Thank you so much for your help, it works perfectly!
I do have another question though. If the email addresses are already included in the data structure provided by the API, how do we make use of them? During the for each loop, we are currently retrieving the relevant email address by using the current record that matches the condition.
Is there a way we can update our entities so that these email addresses are also stored directly in the data entity when saving the Project Grid? This way, the email addresses would always be readily available in our database when we save the project grid data.
I hope I was able to explain what I meant clearly! And again, thanks so much for your help—I really appreciate it. As you can probably tell, I’m a complete beginner, haha!
Looking forward to hearing your advice! 😊
You can handle this the same way you populate the other attributes, inside the column’s OnChange event. Since you already added the email column, make sure to give it a Name so you can reference it, then use SetCellData to assign the value.
If the column needs to be hidden, open the column’s configuration and simply set Visible = False and AllowEdit = False. This ensures the value is stored in the row and available when saving, without showing the column in the UI.
I’ve updated the OML with the implementation. Since the API example didn’t contain an email field, I used a placeholder attribute.
Ahh! Perfect, I wasn't aware that there is the option to hide the columns... thanks!!
To implement email notifications for approaching release dates in an editable Data Grid using OutSystems, you can follow these steps:
Set up the Data Grid and Define Columns: Use the OutSystems Data Grid component to create a grid for managing your releases, including columns such as "Release Date," "Project Name," and any other relevant information. Ensure the columns you want to make editable have the Allow Edit property set to True. For more information on configuring editable columns within the OutSystems Data Grid, refer to OutSystems Data Grid.
Allow Edit
True
Create a Timer or Scheduled Job: Use a Timer in OutSystems to schedule a regular background job (e.g., daily). This Timer will be responsible for checking the "Release Date" column data in the Data Grid.
Logic for Checking Approaching Release Dates: Within the Timer, implement logic to:
Prepare and Send Email Notifications:
Send Email
Test the Full Process:
By combining the Data Grid's editable functionality with a Timer and email notifications, you can create a robust system to alert users of approaching release dates.