Create a user notification system within app

Been bouncing around with this for a while and can't get it to work.

Here's the goal:

  • Create an update record containing text describing app changes and key data.
  • Display those messages in a view for active users.
  • Allow the user to mark the messages read (and then hide) or not to see them again.

I'm comfortable using Jquery to hide views based on data available or not on page renders.

The stumbling block is how to structure the data correctly so that a request to mark messages/notifications read is recorded against the message. I keep coming up against attempts at updating a many-many field to 'add a record' that can't be done without setting the field to one connection.

I think I'm missing something basic here!

Guilhermebastian2 That app looks awesome do you have a preview that someone could see that app anywhere? I love looking at apps built on knack its sad there are so few to see anywhere. I would get so many good ideas seeing other apps like this.. I want the css for that lol

1 Like

I think I was able to create something similar to the original project from this post. I use a table report to show the unread messages, an action trigger to update the status to read and a table view with unread messages filter. I divide the messagens by teams, but I'm sure you can use user also. It looks like this:

Sorry Tony - abandoned this one.

@brad did you ever complete this?

Perhaps another "ReadNotices" object is what you need: each row contains a UserID and a RecordID, the RecordID being the ID of the Update notice. Once a user has read that particular notice, it adds a record to the database of their ID and the RecordID.

Your interface can query the total number of Update notices, and then query the ReadNotices of those that contain the UserID - what's left is the number of unread notices.

Unfortunately, if you have a lot of active users and lots of updates, that can get very record-intensive...

Appreciate your thoughts there Benjamin - I'll post my progress on it here if I get to it!

PS - even if you couldn't use "contains" to pre-filter the notifications from Knack's options, it would be super easy to show or hide using jquery and a substring match on each notification's div.

I have written what you are describing in PHP and it's even complex then when you have complete control. Here are a couple brainstorming-like ideas (not complete solutions) that may help (or not).

1. What if you had a field in the notifications object that kept track of the user's email address delimited by something like a pipe. Then you could use "contains" or "does not contain" as filters to choose which records to show. Since there is no "append" option in Knack, you would probably need to use jQuery to read the current value out of a hidden field, append the current user's email address to the string and then use the API to write it back to the record when the user clicks "Mark as read."

2. Not exactly what you are looking for, but maybe each user could have a "I'm caught up as of" kind of date/time, and then somehow use that to decide which notifications to show based on their post date. This would have to be a blanket per-user solution - I realize it's not the same.

Like I said, I didn't actually try the first, but in concept, I think that it seems plausible. I hope this helps.

Benjamin

Each user has their own read/not read record.

That works easily with a 'User Notification' object and fields for the text and read (yes/no). But how do we create multiple records for every user?

If we try say a single Notification with a many-many connection to users - can't find a way to filter for 'does not contain logged in user', or a way to ADD that user to the connections list and not add a single user. So that fails.

If User Notification is an intermediate table between Users and Notifications, how to filter for Notifications when User Notification for logged on user = 0 can't be done either.

Is the "marked as read" state a global one, or are you trying to make it so that each user has their own state of read/not read for every record?

Brad, did you ever get a solution to this? I am trying to do a similar thing. Within one of my apps users need to send messages to one or more others, and I am stumped on a way to have a grid show for user that tracks if they have read or deleted the message.

No never did @Calvin_B Iā€™m afraid.

No problems @BradStevens I did it with Make in the end. A simple messaging system that records the status of each of the users that have read and deleted the message in a separate table to show the message status for each user. Easy to do for 1:1 but when a user sends the message to many people, I needed to iterate the creation of a record for each user for the status.