Q

Adding buttons and auto-fill fields

I have created a small department database that holds, dept, name, phone, email address, etc. I have created a view that has name, phone, and email (sorted by dept). I would like to add an "Email" button so that the user can "mark" people and then click the button and the program opens a blank memo with the "To" field filled in with all of the peopled that were marked. How is this accomplished? Again, with being a newbie, examples would be great.

I have created a small department database that holds, dept, name, phone, email address, etc.

I have created a view that has name, phone, and email (sorted by dept). I would like to add an "Email" button so that the user can "mark" people and then click the button and the program opens a blank memo with the "To" field filled in with all of the peopled that were marked.

I've been programming for many years, but am relatively new to Notes/Lotus Script programming, so I understand the concept of what needs to be done (read view, fill up array of some sort with people marked, open email with array field in the To field). However, I can't find the proper keywords to use to do this.

How is this accomplished? Again, with being a newbie, examples would be great.

There are two different issues here. The first is how to get the list of selected people. The second is how to compose and send the email. In this case, I am going to assume that you want to manually edit the memo before it is sent. If that were not the case, you could create one in memory and send it very easily:

    Dim session As New notessession
    Dim db As NotesDatabase
 Set db=session.CurrentDatabase
    Dim report As NotesDocument
 Set report=db.CreateDocument
 report.form="Memo"
 report.subject={Your agent "}+session.CurrentAgent+-
         {" in database "}+db.ti+{" has failed.}
 Call report.Send(False,"Bob the Builder@pbs.com")

But to edit the memo before sending, you will need to have a form that you can use to edit it in the UI. Now, you can create a form in your database and give it appropriate fields, but in this case I'm going to show you a different way. You can actually open the user's mail file, create the memo there and let them edit and send it. It's fairly simple to do, but you do have to keep in mind one point. Often, when doing this sort of thing, you will want to add a link to a document, view, or database to the email before you edit it. I've done that below by setting a NotesRichTextItem to point to the body field of the new memo. But for this to work, the new memo document must be SAVED TO DISK before it is opened for edit. Otherwise, what the agent puts in the body field will be lost.

    Public Sub MailxSendWithEdit(ByVal sendto As Object, ByVal subject As String, ByVal remark As String)
        Dim ws As New notesuiworkspace
        Dim session As New notessession
        Dim db As NotesDatabase
        db = session.currentdatabase
        Dim memo As notesdocument

        'Create memo... 
        memo = db.createdocument
        memo.form = "Memo"
        memo.subject = subject
        memo.sendto = sendto
        Dim rtitem As New notesrichtextitem(memo, "Body")
        Call rtitem.appendtext(remark)

        On Error Resume Next

        'Optionally add some text and links before editing... 
  Call rtitem.appendtext(Chr(10)+{Something has happended…} )
        Call rtitem.appendtext(Chr(10))
  Call rtitem.appendtext(Chr(10)+_
             {Follow this link to the databasse-->})
        Call rtitem.appenddoclink(db, "Link")

        'Find the user's mail file... 
        Dim usermailfile As Variant
     usermailfile=Evaluate({@MailDbName})
        Dim maildb As New notesdatabase(usermailfile(0), usermailfile(1))
        Dim memo1 As notesdocument, uidoc As notesuidocument

        'Save the memo, then copy it's contents to a new memo in the mailbox... 
        Call memo.save(True, False, False)
        unid = memo.universalid
        memo = session.currentdatabase.getdocumentbyunid(unid)
        memo1 = maildb.createdocument
        Call memo.copyallitems(memo1, True)
        Call memo.remove(True)

        'Then open the document for editing. . . 
        uidoc = ws.editdocument(True, memo1, False)
        If memo1.sendto(0) <> "" Then
            Call uidoc.gotofield("Body")
        End If

Now, I realize I haven't answered the core question: "How do I get the list of names?" That's easy, we use a standard code snippet to walk the view. And here it is:

       ' Get collection of all selected documents. 
 Set Selected=db.UnprocessedDocuments              
       Dim sendTo As New NotesItem(memo, "SendTo")

       ' process selected documents (In random order ). 
 For i=1 To Selected.Count                                               ' 
  Set doc=Selected.getnthdocument(i)   

  sendto.AppendToTextList(doc.from)

 Next ' i

Here I have modified a standard "walk selected" pattern to insert the senders into the "SendTo" field of the memo we are constructing.
This was first published in September 2006

Dig deeper on LotusScript

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close