0

I'm building a custom Notification section, which provides notification or messages to multiple users on any particular object update, I've created a Custom page where I have added a Alert section or notification section, which shows a particular record updates, like there is a custom object lets call it CustomObjA, whenever a record is created or updated with some specific data into that custom object, for that update a message record is generated and which showed on user on the Notification section. now As moment user click or expend the notification section. that notification should be grayed out, means it is seen by that particular user, and next time when that user come to that page it should grayed out those notification which are seen/read by user. So its like our Email read/unread functionality.

how to achieve this functionality.

What I have done so far, I have created a new object called Notification and every time whenever there is any create or update on that custom object (CustomObjA), I wrote a trigger which create a new record in notification object and I'm reading that notification object all the time. On the notification I have created a field called "Status" which include Read/Unread option. Now I want your help to figure out how to set that field as "Read" on basis of every individual user.

P.S. - There are multiple users who sees this notification functionality, so if a UserA seen the message it doesn't mean that UserB also seen that, so userB still able to see that unread mark on the same message in the notification section.

Let me help what's the best way to achieve that.

Thanks in advance!

  • Istead of putting it hold if you guys think about the solution, it will really help the community. Kudos to Santanu, learn something if you can – user2809299 Dec 28 '16 at 9:23
1

Whatever you have done till now seems good. But since you have many-to-many relationship between User & Notification, you will need a junction object to record whether a particular user has read a notification or not.

Create another object called - NotificationStatusPerUser and have User & Notification as parents. So everytime a User reads a notification, a record will be entered here for that User & that particular notification.

So when another user opens the page, you search through the records of this NotificationStatusPerUser object and see whether their is a record for this User & this Notification, if yes, he has already read the Notification, else he has not.

----OR----

The second best way is to have a long text field(say ReadBy) in Notification which will hold the Ids of the users who has already read the notification in a semicolon separated list. So data in this field will be like-

0054C000000YpDQQA0;0054C000000YpGHYA0;0054C00000UH6QQA0;0054CJHHJUYGpDQQA0

Now, when you load the page, you search in this field whether the current user's id is present or not, if yes, notification is read for him, else no.

Please note, since there is a limit on the length of the field value, if you have large number of users this approach will not work.

Let me know if you have any questions.

|improve this answer|||||
  • Santanu, I have large number of users, but I think second approach is feasible to me because, in that I don't need to create any extra records in DB. – user2809299 Dec 28 '16 at 9:07
  • By the Way, I can use Long Text area with maximum limit. And I'm pretty much sure it will work for me. – user2809299 Dec 28 '16 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.