• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Multiple selections in agent

Have an agent which is triggered by a button, I am having trouble getting the code right so it will allow me to select multiple docs from a view and have the code below run on each. What adjustments can I try to get this to work.


Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim emaildoc As NotesDocument
      Dim Item As NotesItem
      Dim i As Integer
      Dim rtitem As NotesRichTextItem
      Dim dc As NotesDocumentCollection
      Set db = session.CurrentDatabase
      Set dc = db.UnprocessedDocuments
      
      On Error Resume Next
      Set doc = dc.GetFirstDocument
      For i = 1 To dc.Count
            Set doc = dc.GetNthDocument( i )
            If doc.invited_flag(0)<>"done" Then
                  Set emaildoc = db.CreateDocument
                  emaildoc.form = "bb_invite" 'Form name of Letter
                  emaildoc.SendTo = doc.EE_Name(0)
                  emaildoc.CopyTo = "Field Technology"
                  emaildoc.BlindCopyTo = doc.bcc
                  emaildoc.Principal = "Field Technology"
                  emaildoc.Subject ="MetLife BlackBerry offer extended to " +  doc.EE_Name(0) + "!"
                  emaildoc.EE_Name = doc.EE_Name
                  emaildoc.ReturnReceipt="1"
                  Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
                  Call rtitem.AppendDocLink(doc, "")
                  Call emaildoc.Send(True)
                  doc.invited_flag = "done"    'field name for flag
                  doc.status = "Offer Sent"
                  Call doc.Save(True,True)
            End If
      Next
End Sub
0
jforget1
Asked:
jforget1
  • 3
  • 3
  • 3
1 Solution
 
SysExpertCommented:
This appears to be correct in general.
The dc should contain the selected docs for processing.

I would consider doing get first ad get next rather than get nth doc.

What appears to be the problem ?

I hope this helps !

0
 
jforget1Author Commented:
It only sends the doc that is highlighted and not the others which I have placed a check next to. Not sure what the problem is.
0
 
behendersonCommented:
Goto the DocumentSelection Section and then open a properties box

In the properties box make sure selected documents is chosen
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
jforget1Author Commented:
Do you mean in debugger?
0
 
behendersonCommented:
In the agent window when you ar coding the agent (I am assuming you are in 6.5) there is Declarations Initialize Options and DocumentSelection
0
 
SysExpertCommented:
It is also in the Target section of the Agent properties.

Make sure it is set to
All selected docuemtns.

I hope this helps !
0
 
SysExpertCommented:
Actually in the Runtime Section, Target Field.
0
 
jforget1Author Commented:
Oh my god that was it, something so simple, should have picked that up.
0
 
behendersonCommented:
If you are in an older version it is in the agent window which documents should this act on
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now