Subscription by Category - Code

Posted on 2002-04-04
Last Modified: 2013-12-18
I am looking to establish a subscription function in a Lotus Notes database.  There is a dialog-list field named "Category" in the "Main" Form, and this field can take on values of say Apples, Bananas, Cherries, etc.  We'd like to allow the user to subscribe/unsubscribe to any (one or multiple) of these catgegories, so that when he is subscribed to the Apples category, anytime a document having this category is saved (either new or updated doc), all the subscribed users would get an automatic email.

Does anyone know if there is some canned code available that has such a subscribe function?
Question by:blyons48
LVL 10

Expert Comment

ID: 6918949
Normally are notifications sent daily, but if you prefer, change the schedule from OnceDaily to DocumentsBeenCreatedOrModified. Agent gets in both cases the correct collection of modified documents.
Best example is the Lotus TeamRoom template and its Interests profiles. Look for SendNewsletters agent.

I know that this is too powerful for your needs, but on other hand you ask for specific Category settings. I have tried to help one time ago to develop a simple booking concept to one questioner. Believe or not, this is soon a never ending story, you can not take from another concept, you have to develop it on your oven and drive it in your direction. Sorry...
LVL 13

Expert Comment

ID: 6918996
Did it once....

I used a separate subscription database. This allowed me to use only one subscription database for numerous other databases.
Database owners could (with help of Admin) introduce new topics and link them to certain mail groups.
For every user, I recorded the topics that he / she is subscribed to. selectable topics were retrieved from the owner-defined list and presented as checkboxes.
I recorded subscriptions on a normal documents, not profile documents, to be able to collect all subscriptions containing a specific topic from a view. Documents would be protected by author / reader names field to allow only the user and a specific userrole (for server / agents / db owner and/or admin).

Documents would appear in two views:

A: sorted by username (to be able to find the subscriptions for every user),

B: sorted by topic (needed to collect all users, subscribed to the same topic)

An agent, triggered by document changes, would, for each topic, collect usernames from view B and store the result in a mailgroup-document in the NAB. Mail can easily be sent (automatically) to such pre-defined groups.

After that I fine-tuned the system in several phases. The most important and easy to implement was the addition of several sub-groups. Due to the amount of users I had to define additional groups for each topic, e.g. usernames A-F, G-L, M-S, T-Z. These groups were held in the original "main" group to which the mail was send.

Other changes made it possible to update only the additions / deletions to groups. I would not recommend to try to implement that right now. Could cost you an awfull lot of additional time and might cause a lot of errors / discrepancies.
LVL 24

Accepted Solution

HemanthaKumar earned 100 total points
ID: 6921221
Let me give you a simple approach.

Let us say you have a field called 'Category' and two buttons namely, Subcribe and Unsubscribe

Subscribe Will contain this code on CLick event

Sub Click(Source As Button)
     Call Subscription( "Subscribe" )
End Sub

Similarly for Unsubscribe
Sub Click(Source As Button)
     Call Subscription( "UnSubscribe" )
End Sub

Here is the main function "Subscription" which will be declared as global.

Function Subscription( Flag As String )
     Dim ws As New NotesUIWorkspace
     Dim note As NotesDocument
     Set note = ws.CurrentDocument.Document
     Dim s As New NotesSession
     Dim db As NotesDatabase
     Dim pDoc As NotesDocument     ' Parameter document
     Set db = s.CurrentDatabase
     Set pDoc = db.GetProfileDocument( "ParameterDoc")    
     subscriber = s.UserName
     Forall opts In note.Category
          If opts = "" Then Exit Function
          If pdoc.HasItem(opts) Then
               Set item = pdoc.GetFirstItem(opts)
               Set item = pdoc.ReplaceItemValue(opts, Null)
          End If
          Select Case Ucase(Flag)
          Case "SUBSCRIBE":
               If Not item.Contains(subscriber) Then
                    Call item.AppendToTextList(subscriber)
               End If
          Case "UNSUBSCRIBE":
               count = 0
               Forall v In item.values
                    Redim Preserve strarr(count) As String
                    If v <> subscriber Then
                         strarr(count) = v
                         count = count + 1
                    End If                    
               End Forall
               Set item = pdoc.replaceItemValue(item.Name, strarr)
          End Select
     End Forall
     item.IsNames = True
     Call pdoc.Save(False,False)
End Function

The next part would be for mailing. I am assuming that you want to just notify user that document has been changed/saved by someone. So create a computefordisplay field with following formula in it.

SendTo := @GetProfileField( "ParameterDoc"; Category);
@if( SendTo = ""; @Return(0); "");
@If(@IsDocBeingSaved; @MailSend( SendTo ; "" ;""; "Following document has been changed" ; "Click on the doc link for more info, " ;"" ; [IncludeDoclink] ); "")



Author Comment

ID: 7222401
Excellent, thanks.
LVL 24

Expert Comment

ID: 7222502
Thank you for A Grade

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Migrating to Exchange 2013 4 45
Clean URL from GET variables 2 101
Advice on what platform to use for a web app for AWS 3 98
Grunt Copy file to another destination. 1 37
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question