All,
I am stumped. I have a document collection that writes to a mailsend. However on the one section I need to write only the unique items. Here is the collection area of the code, if you need to see more then please tell me:
For i%=1 To n
Set doc = dc.GetNthDocument(i%)
Call rtitem.AddNewline(1)
Call rtitem.AppendText(Fulltrim( " " & doc.Author(0) & " " & doc.Phone(0)) )
Call rtitem.AddNewline(1)
Call rtitem.AppendText( Fulltrim(" " & doc.Contact(0) & " " & doc.PubPhone(0)))
Next
This will write to the Body of the mail and add each instance of information found from all documents. Such as:
John Doe ABC/1238
Jill Doe ABX/1289
John Doe ABC/1238
What I would like for it to do is:
John Doe ABC/1238
Jill Doe ABX/1289
I have tried something like this:
For i%=1 To n
Set doc = dc.GetNthDocument(i%)
Call rtitem.AddNewline(1)
who = ( " " & doc.Author(0) & " " & doc.Phone(0)) )
who2 =( " " & doc.Contact(0) & " " & doc.PubPhone(0)))
Next
Call rtitem.AddNewline(1)
Call rtitem.AppendText( Fulltrim(who))
Call rtitem.AddNewline(1)
Call rtitem.AppendText( Fulltrim(who2))
**********Finish writing the mailsend here
Only gives me the first item that the code runs into, not the list. So obviously I have coded it incorrectly.
TIA,
Teri
Subject: Document Collection Help
Teri
First of all getnth document is very slow. What I might do is create a list and then print only those that are unique such as
dim lstName list as boolean
set doc = dc.getFirstDocumet()
while not doc is nothing
name = doc.GetItemValue( “Author”)
if isElement( lstName( name)) = false then
print your name
lstName( name) = true
end if
set doc = dc.GetNextDocument( doc)
wend
Subject: Document Collection Help
Something like this maybe
Dim auth ( 1 to n ) as String
For i%=1 To n
Set doc = dc.GetNthDocument(i%)
auth(n) = doc.Author(0)
Next
auth = ArrayUnique(auth) ’ remove duplicates
Forall a in auth
Call rtitem.AddNewline(1)
Call rtitem.AppendText(a)
End Forall
Subject: RE: Document Collection Help
Paul thanks for the info.
I have tried putting this into the formula but al getting an Illegal reference to array or List: AUTH on the: Dim auth (1 to n) As String line.
If I remove that line from the code then I get an Illegal array bound for (AUTH).
I I remove the (1 to n) reference in the Dim auth ( 1 to n) as String then all errors are removed but nothing is being returned.
In Help I found: ***************
You used the name of an array or list in an illegal context. Illegal contexts include the following, where X is the name of an array or list:
As the target of an assignment or Set statement, as in X = Y, Set X = Y, Set X = New Y, Set X = Bind Y
As the target of a Delete statement, as in Delete X
As though it were an object reference variable or a variable of a user-defined data type and you were referring to one of its members, as in X.Y
Before I received your code I tried:
For j=1 To n
Set doc = dc.GetNthDocument(j)
m = ( " " & doc.Author(0) & " " & doc.Phone(0))
Next
Call rtitem.AddNewline(1)
Forall k In m
Call rtitem.AppendText (m )
Call rtitem.AddNewline(1)
End Forall
The above code was only giving me the last items of the array.
Teri
Subject: RE: Document Collection Help
Please post your complete code. Posting partial code it’s difficult to know exactly what you are doing and where you are doing it.
Subject: RE: Document Collection Help
Here is the complete code:
I have remmed out the working code that grabs all information from the doc collection for the contact information. I am trying to chane it to grab only the unique values. That is the section that I am unsuccessful with.
Thanks in Advance,
Teri
After changing the problem area to:
Dim auth () As String
Dim auth2 As Variant
For i%=1 To n
Set doc = dc.GetNthDocument(i%)
auth(n) = doc.Author(0)
Next
auth2 = Arrayunique(auth) ' remove duplicates
Call rtitem.AddNewline(1)
Call rtitem.AppendText( auth2 )
This did not throw errors, but did not return any results. I ran the debugger (did not throw errors) and found that the auth(n) was not capturing the doc.Author(0) information.
Sub Initialize
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim key As String
Dim uidoc As NotesUIDocument
Dim MSVLdb As NotesDatabase
Dim MSVLview As NotesView
On Error Resume Next
'#####################################################
'Collect the number from the current document
'#####################################################
Set uidoc = workspace.CurrentDocument
key = uidoc.FieldGetText( "Prefix") + uidoc.FieldGetText( "ECRNum")
check = uidoc.FieldGetText( "CSRMailSend")
If check = "Yes" Then
Else
Exit Sub
End If
'#####################################################
'Find second DB and matching doc, then send agent
'#####################################################
Dim w As New NotesUIWorkspace
Dim rtitemA As Variant
Dim dc As NotesDocumentCollection
Dim collection As NotesDocumentCollection
Set w = New NotesUIWorkspace
Set MSVLdb = session.GetDatabase("Edison/SEL","MFG\LITFAIReco.nsf")
Set MSVLview = MSVLdb.GetView( "(ECO Lookup)" )
Set dc = MSVLview.GetAllDocumentsByKey(key , True )
Dim n As Integer
n = dc.Count
Set doc = dc.GetFirstDocument()
'########################################################
'Get the e-mail information together
'#######################################################
Dim senddoc As NotesDocument
Dim db3 As NotesDatabase
Set db3 = session.CurrentDatabase
Set senddoc = New NotesDocument (db3)
Dim recip(6) 'Adding in this array so that I can send to more then one
recip(0) = "Teri Colvin"
recip(1) = "Teri Colvin"
recip(2) = "Teri Colvin"
recip(3) = "Teri Colvin"
recip(4) = "Teri Colvin"
recip(5) = "Teri Colvin"
senddoc.SendTo = recip
senddoc.CopyTo = ("Teri Colvin")
senddoc.Form="Memo"
senddoc.Subject = "MSVLDB: Literature Distribution Information for " + key
Dim rtitem As New NotesRichTextItem (senddoc, "Body")
Set rtitem = New NotesRichTextItem (senddoc,"Body")
Dim richStyle As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle
richStyle.FontSize = 12
richStyle.Bold = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AppendText("This project has been Production Released." )
Call rtitem.AddNewline(1)
Call rtitem.AppendText( " The Contact person, Phone/Mail Code/Location: " )
'####################################################################
'Find the contact information for top of mail
'####################################################################
'For j=1 To n
' Set doc = dc.GetNthDocument(j)
' Call rtitem.AddNewline(1)
' Call rtitem.AppendText (Fulltrim( " " & doc.Author(0) & " " & doc.Phone(0)) )
' Call rtitem.AddNewline(1)
' Call rtitem.AppendText (Fulltrim( " " & doc.Contact(0) & " " & doc.PubPhone(0)) )
'
'Next
'***********Testing below section to try and grab only unique items****************************************
'******************************************************
Dim auth As Variant
For i%=1 To n
Set doc = dc.GetNthDocument(i%)
auth(n) = doc.Author(0)
Next
auth = Arrayunique(auth) ' remove duplicates
Forall a In auth
Call rtitem.AddNewline(1)
Call rtitem.AppendText(a)
End Forall
'************************************************************************
'***********End testing to grab only unique items*******************************************************************
Call rtitem.AddNewline(2)
richStyle.Bold = False
richstyle.Underline = True
richStyle.NotesColor = COLOR_BLACK
Call rtitem.AppendStyle(richStyle)
Call rtitem.AppendText("The following literature is now available for ordering." )
Call rtitem.AddNewline(1)
richStyle.Bold = False
richstyle.Underline = False
richStyle.NotesColor = COLOR_BLACK
richStyle.FontSize = 8
Call rtitem.AppendStyle(richStyle)
'####################################################
'Create Table
'#####################################################
Dim styles(1 To 8) As NotesRichTextParagraphStyle
For i% = 1 To 8
Set styles(i%) = session.CreateRichTextParagraphStyle
styles(i%).LeftMargin = 0
styles(i%).FirstLineLeftMargin = 0
If i% = 1 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER * 1.5
Elseif i% = 2 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER *2
Elseif i% = 3 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER *2
Elseif i% = 4 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER * 3
Elseif i% = 5 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER * 2.5
Elseif i% = 6 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER * 1.5
Elseif i% = 7 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER * 1.5
Elseif i% = 8 Then
styles(i%).RightMargin = RULER_ONE_CENTIMETER * 1.5
End If
Next
Call rtitem.AppendTable(n+1 ,8, , RULER_ONE_INCH, styles)
'Populate table column title
richStyle.FontSize = 8
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
Dim rtnav As NotesRichTextNavigator
Set rtnav = rtitem.CreateNavigator
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 1)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("Type")
Call rtitem.EndInsert
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 2)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("Part #")
Call rtitem.EndInsert
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 3)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("Datecode")
Call rtitem.EndInsert
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 4)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("Title")
Call rtitem.EndInsert
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 5)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("CD's")
Call rtitem.EndInsert
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 6)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("Weight")
Call rtitem.EndInsert
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 7)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("Binding")
Call rtitem.EndInsert
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 8)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText("Comments")
Call rtitem.EndInsert
'Populate table contents
For i%=1 To n
Set doc = dc.GetNthDocument(i%)
richStyle.NotesColor = COLOR_BLACK
richStyle.Bold = False
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.New(0))
Call rtitem.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.PartNum(0))
Call rtitem.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.DateCode(0))
Call rtitem.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.Description(0))
Call rtitem.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.CDPart(0))
nex = doc.CDPart_1
If nex Is Nothing Then
Else
Call rtItem.AppendText(", " & nex)
End If
Call rtitem.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.ShipWeight(0))
Call rtitem.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.Binding(0))
Call rtitem.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendStyle(richStyle)
Call rtItem.AppendText(doc.PubComments(0) )
Call rtitem.EndInsert
Next
Call rtItem.AddNewLine(3)
richStyle.Bold = False
richStyle.NotesColor = COLOR_BLUE
Call rtitem.AppendStyle(richStyle)
Call rtitem.AppendText("Part Number Code:" )
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" AG - Application Guide")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" FUI - Firmware Upgrade Instruction")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" LAN - Literature Application Note")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" LCS - Literature Case Study")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" LDG - Literature Quickset Design Template")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" LM - Literature Miscellaneous")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" LP - Literature Miscellaneous Paper and Documents")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" LTE - Employee Development Training Materials")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" LWP - Literature White Paper")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" PDS - Production DataSheet")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" PF - Production Flyer")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" PGS - Production Guideform Spec")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" PLS - Production Literature Sheet")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" PM - Production Manual")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" PSK - Production Sales Kit")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" SELU - Schweitzer Engineering Laboratories University")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" SEM - Seminar")
Call rtitem.AddNewline(1)
Call rtitem.AppendText(" TP - Technical Paper")
Call senddoc.ComputeWithForm(False,False)
'####################################################
'Send the mail
'#####################################################
Call senddoc.Send( True )
End Sub
Subject: Document Collection Help – Updated info
I have added in a Redim and changed the problem code to this:
Dim auth () As String
Dim auth2 As Variant
For i%=1 To n
Set doc = dc.GetNthDocument(i%)
Redim auth(0 To n)
auth(n) = doc.Author(0)
Next
auth2 = Arrayunique(auth) ' remove duplicates
Forall a In auth2
Call rtitem.AddNewline(1)
Call rtitem.AppendText(a)
End Forall
No errors are thrown, however only the last name found was appended to the text. I did see the code cycling through the documents looking for the Author names. However it was not collecting them it was replacing them. The Variable started with [“”,“”,“”,“”,“”,“”,…], then with the new doc would show [“”,“”,“”,“”,“”,“”,“Jill Jones”], and then [“”,“”,“”,“”,“”,“”,“Sara Smith”], and [“”,“”,“”,“”,“”,“”,“Peter Piper”], always replacing the last name in the array never adding to the array. Then the name that would be wrote to the body was “”, Peter Piper.
1-6 items in the array stay static with nothing in them. Then on each look at the collection the 7th item on the array changes.
Any suggestions?
Thanks
Teri
Subject: RE: Document Collection Help – Updated info
use redim preserve to keep the values