Solved

Subscription by Category - Code

Posted on 2002-04-04
5
785 Views
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?
0
Comment
Question by:blyons48
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 10

Expert Comment

by:zvonko
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...
0
 
LVL 13

Expert Comment

by:CRAK
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.
0
 
LVL 24

Accepted Solution

by:
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)
          Else
               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] ); "")

~Hemanth


0
 

Author Comment

by:blyons48
ID: 7222401
Excellent, thanks.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7222502
Thank you for A Grade
0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

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.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

631 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