11
Views
8
Comments
Solved
List notifications separated by date
Application Type
Reactive

Hi everyone.

I have an entity {Notification} with the following attributes: SenderId, ReceiverId, Content, DateTime.

When a user opens a notification tab, i want a list to appear with all the notifications whose receiver is the current user, but listed separately by dates, like the image below: (the rectangles are the notifications sent on each day)

What i tried to do: I made a ListBlock that has an expression for the Date and a list where each list item is a NotificationBlock:

And then in the main screen, i use this ListBlock as a list item, so that there is a list of dates and their notifications.

Now, my problem is: how do i get a list of all the UNIQUE dates present in my records? For example: i might have 10 records of notifications sent on 20th of december, but i want to save the date 20-12-2020 only once to a list of dates, so that i can populate de List of ListBlocks with that Date List (i hope that is clear?). 

Another challenge to this is that My [Date] attribute in {Notification} is of type DateTime. so i've tried to only save unique dates but it still saves all the dates because the Time part of the DateTime is always different.

Let me give another example:

Notif1 | #12-01-2021 12:11:25#

Notif2 | #12-01-2021 10:32:50#

Notif3 | #12-01-2021 09:51:05#

Notif4 | #30-12-2020 12:01:25#

Notif5 | #30-12-2020 08:56:55#

From this list of records, all Times are different but there 2 different dates, with multiple records on that date. I want to save to my DateList ONLY: 12-01-2021 and 30-12-2020. (only once each date)


In conclusion: how do i create a list of unique dates from my {Notification} records?

mvp_badge
MVP
Rank: #73
Solution

Hi Ines,

Refer to the attached updated .oml file for the mentioned use-case.

Implemented Points

  • I have added an ad-hoc attribute called NotificationDate in the Screen aggregate as well as in the block aggregate to convert the DateTime attribute (Date) value to date.
  • Screen List Widget - Sets all of the available notification Date (Aggregate with GroupBy clause on NotificationDate ad-hoc attribute)
  • Notification Block List Widget - Showcase set of Notification content based on each Date (Aggregate defined with NotificationDate = CurrentNotificationDate filter condition)


PS: Please change the Notification Block Input parameter name to - CurrentNotificationDate


Hope this helps you!


Kind regards,

Benjith Sam

ListByDate.oml

Rank: #286
Solution

Hi Ines,

Thanks for the OML, but i have already created a sample OML to help you with the implementation of how to show Notifications separated by date.

Please find attached OML herewith.

Hope this helps, Thanks :)


NotificationsDemo.oml

Rank: #286

Hi Ines,

Could you please share an OML for this scenario so that we can look into and give you desired solution?

Thanks :)

Rank: #5927

Hi, yes here is a model .oml 

ListByDate.oml

Rank: #286
Solution

Hi Ines,

Thanks for the OML, but i have already created a sample OML to help you with the implementation of how to show Notifications separated by date.

Please find attached OML herewith.

Hope this helps, Thanks :)


NotificationsDemo.oml

Rank: #5927

thank you so much! this definitely helped with some of the block building. but, this still lists the same Date multiple times (as many times as there are records with the same date). How do i list the notifications of one date only once?

mvp_badge
MVP
Rank: #73
Solution

Hi Ines,

Refer to the attached updated .oml file for the mentioned use-case.

Implemented Points

  • I have added an ad-hoc attribute called NotificationDate in the Screen aggregate as well as in the block aggregate to convert the DateTime attribute (Date) value to date.
  • Screen List Widget - Sets all of the available notification Date (Aggregate with GroupBy clause on NotificationDate ad-hoc attribute)
  • Notification Block List Widget - Showcase set of Notification content based on each Date (Aggregate defined with NotificationDate = CurrentNotificationDate filter condition)


PS: Please change the Notification Block Input parameter name to - CurrentNotificationDate


Hope this helps you!


Kind regards,

Benjith Sam

ListByDate.oml

Rank: #5927

thanks everyone, with a mix of your answers i was able to completely fix my problem :) but i still had to use ListDistinct Action to get a List of only one time each date.

Thank you!

mvp_badge
MVP
Rank: #73

You're welcome, Ines.

Glad to help you :)

Still, I'm a bit confused, why do you need to use ListDistinct action - instead GroupBy on the newly defined Ad-hoc attribute i.e. NotificationDate = DateTimeToDate(Date) in the Screen Aggregate should work in your case.


Kind regards,

Benjith Sam

Rank: #5927

I did this "NotificationDate = DateTimeToDate(Date)  " on the notification block. and used GroupBy. But on the Screen, i also used GroupBy, but it still listed the same date multiple times. on the screen, considering i have no 'Date' input like in the block, how could i use DateTimeToDate(Date)? i use it in the block but in the screen i couldnt use it so it listed the notifications by date, but still listed the same List (with same date) multiple times.