Help with script

Hi

I’m a newbie when it comes to script. I got help with a script to create an e-mail for the docs library, it works great. Now I just need to find a away to not send the doc and to be able to pick the address for the e-mail and not have it coded in the script. The reviewer thing doesn’t work for my users cause they don’t like that is creates a “copy” of the orginal document and then a response from everyone etc. They just want to notify certain people when a doc has been put in the library. Here is the current script.

The following replaces the existing code in the Declarations section of Globals for the Document form


Dim FormW As NotesUIWorkspace

Dim FormDoc As NotesUIDocument

%INCLUDE “lsconst.lss”


The code below replaces the existing code in the Queryclose event of the Document form


Sub Queryclose(Source As Notesuidocument, Continue As Variant)

    Dim rtitem As Variant 

    

    Dim session As New NotesSession 

    Dim db As NotesDatabase 

    Dim doc As notesdocument 

    Set db = session.CurrentDatabase 

    Set doc = source.Document 

    

    If Source.EditMode Then 

            

            

            Dim answer As Long 

            answer = Messagebox ("Do you want to send notification to reviewers that this doc has been updated?", MB_YESNO,"") 

            If ( answer = IDYES )Then 

                    Dim memo As NotesDocument 

                    Dim mailitem As NotesItem 

                    Dim mailrtitem As NotesRichTextItem 

                    Dim docsubject As String 

                    

                    Set mailitem = doc.GetFirstItem( "Subject" ) 

                    docsubject = mailitem.Text 

                    Set memo = New NotesDocument( db ) 

                    memo.Form = "Memo" 

                    memo.Subject = "The document "+docsubject+" has been updated, please review." 

                    

                    Set memo = New NotesDocument( db ) 

                    ' This sets the form name and subject 

                    

                    Set mailitem = doc.GetFirstItem( "Subject" ) 

                    docsubject = mailitem.Text 

                    memo.Form = "Memo" 

                    memo.Subject = "The document "+docsubject+" has been updated, please review." 

                    

                 ' This creates the information in the Body of the mail message 

                    Set mailrtitem = New NotesRichTextItem( memo, "Body" ) 

                    Call mailrtitem.AppendText( "Here is a link to the document  " ) 

                    Call mailrtitem.AppendText( "with the subject : " + docsubject ) 

                    Call mailrtitem.AddNewLine(2) 

                    Call mailrtitem.AppendDocLink( note, db.Title ) 

                    

                    'This sets the names of the recipients 

                    Dim recipients( 1 To 3 ) As String 

                    recipients( 1 ) = "Kim Larson/Interaction" 

                    recipients( 2 ) = "Kim Larson/Interaction" 

                    recipients( 3 ) = "Kim Larson/Interaction" 

                    Call memo.Send( False, recipients ) 

                    

            End If 

    End If 

    

    If note Is Nothing Then Exit Sub 

    If Not(note.HasItem("CopyBody")) Then Exit Sub 

'we already copied the rest of the document, now we need to copy the body field

    Set savenote = db.GetDocumentByUNID(note.OriginalSaved(0)) 

    If note.HasItem("Body") Then 

            Set rtitem = note.GetFirstItem("Body") 

            savenote.RemoveItem("Body") 

            Call rtitem.CopyItemToDocument(savenote, "Body") 

    End If 

    savenote.save True, True, True 

    note.RemoveItem("CopyBody") 

    note.save True, True, True 

End Sub


The subject of the email is defined by this string, it takes the subject line of the document in “docsubject”

                    memo.Subject = "The document "+docsubject+" has been updated, please review." 

The content of the email includes a link to the document in the Doc Library database

Put the mail addresses for your recipients in the following section, you can make this whatever number of users you wish.

                    Dim recipients( 1 To 3 ) As String 

                    recipients( 1 ) = "user name/company" 

                    recipients( 2 ) = "user name/company"

                    recipients( 3 ) = "user name/company"

Subject: help with script

I don’t see anything in this code that would create a copy of the document. What you’re describing sounds like version control has been enabled for the form. Read about “Version Tracking” in the Domino Designer help.

As for picking the email recipients, this sounds like a good application for a multivalued Names field on your form – you could read the value of the field (let’s call it Reviewers) as follows

Dim recipients

recipients = doc.GetItemValue(“Reviewers”)