Solved

Multiple selections in agent

Posted on 2006-11-21
9
241 Views
Last Modified: 2013-12-18
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
Comment
Question by:jforget1
  • 3
  • 3
  • 3
9 Comments
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
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
 

Author Comment

by:jforget1
Comment Utility
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
 
LVL 8

Accepted Solution

by:
behenderson earned 500 total points
Comment Utility
Goto the DocumentSelection Section and then open a properties box

In the properties box make sure selected documents is chosen
0
 

Author Comment

by:jforget1
Comment Utility
Do you mean in debugger?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:behenderson
Comment Utility
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
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
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
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
Actually in the Runtime Section, Target Field.
0
 

Author Comment

by:jforget1
Comment Utility
Oh my god that was it, something so simple, should have picked that up.
0
 
LVL 8

Expert Comment

by:behenderson
Comment Utility
If you are in an older version it is in the agent window which documents should this act on
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now