Multi-value field in LotusScript

I’ve searched through this forum to find my answer and I have had no luck. I’m trying to pull in a multi-value field with LotusScript. The values in this field are being used to send an email notifcation as the CC recipients. For some reason, its not working. Here’s my code:

Sub Initialize

On Error Goto processerror

Dim recips(2) As Variant

Set session = New NotesSession

Set db = session.CurrentDatabase

Set wDoc = session.DocumentContext 'the in-memory document.

Set MemoDoc = New NotesDocument(db)

Dim rtitemStyle As NotesRichTextStyle

Set rtitemStyle = session.CreateRichTextStyle

Set rtitem = New notesrichtextitem(MemoDoc,"Body")



MemoDoc.Form = "Memo"

Call wDoc.Save(True,False)

Dim managers As Variant

managers = wDoc.getitemvalue("d_manager")



If wDoc.FormName(0) = "OIG40" Then

	MemoDoc.SendTo = "IAB-AssaultThreat_Group"

	MemoDoc.SendTo = managers

Elseif  wDoc.FormName(0) = "HRM40" Then

	Dim HRMRecipients(2) As Variant

	HRMRecipients(0) = "Marianne Harris"

	HRMRecipients(1) = "Frank Risler"

	HRMRecipients(2) = "Deborah Clarkson"

	MemoDoc.SendTo = HRMRecipients

End If



MemoDoc.Subject= "Assault /Threat Report"



Call rtitem.addnewline(1)

Call rtitem.addnewline(1)

Call rtitem.appendtext("An assault threat report has been submitted by " & wDoc.RequesterName(0) )

Call rtitem.addnewline(1)

Call rtitem.addnewline(1)



Set serName = New notesname(db.server)

'the line below is to open it up on the browser...not the doclink

Call rtitem.appendText("http://" +serName.Common+"/" & Db.filename & "/(DocID)/" & wDoc.UniversalID & "?OpenDocument" )

'Call rtitem.appendDoclink(wDoc,"")

Call MemoDoc.send(False)



dbserver$ = db.server

Dim dbservername As New notesname(dbserver$)

host$ = dbservername.common

dbpath$ = db.filepath

If Instr(dbpath$,"\") <> 0 Then

	Mid$(dbpath$,Instr(dbpath$,"\"),1) = "/"

End If



href$ = "/" & dbpath$ & "/Web Report Processed?OpenPage"	

url$ = "http://" & host$ & href$

Msgbox url$

Print "[" & url$ & "]" 



Exit Sub

processerror :

Msgbox "Error" & Str(Err) & ": " & Error$,16,"Submit"

Exit Sub

End Sub

Subject: How is it not working?

Does it generate an error?Does it get sent to a single person?

Does it not get sent at all?

Where do you set the CCs I don’t see it in your code?

More information will help others help you.

Subject: RE: How is it not working?

Sorry…the 2nd SendTo is supposed to be CopyTo…see below:

Sub Initialize

On Error Goto processerror

Dim recips(2) As Variant

Set session = New NotesSession

Set db = session.CurrentDatabase

Set wDoc = session.DocumentContext 'the in-memory document.

Set MemoDoc = New NotesDocument(db)

Dim rtitemStyle As NotesRichTextStyle

Set rtitemStyle = session.CreateRichTextStyle

Set rtitem = New notesrichtextitem(MemoDoc,“Body”)

MemoDoc.Form = “Memo”

Call wDoc.Save(True,False)

Dim managers As Variant

managers = wDoc.getitemvalue(“d_manager”)

If wDoc.FormName(0) = “OIG40” Then

MemoDoc.SendTo = “IAB-AssaultThreat_Group”

MemoDoc.CopyTo = managers

Elseif wDoc.FormName(0) = “HRM40” Then

Dim HRMRecipients(2) As Variant

HRMRecipients(0) = “Marianne Harris”

HRMRecipients(1) = “Frank Risler”

HRMRecipients(2) = “Deborah Clarkson”

MemoDoc.SendTo = HRMRecipients

End If

MemoDoc.Subject= “Assault /Threat Report”

Call rtitem.addnewline(1)

Call rtitem.addnewline(1)

Call rtitem.appendtext("An assault threat report has been submitted by " & wDoc.RequesterName(0) )

Call rtitem.addnewline(1)

Call rtitem.addnewline(1)

Set serName = New notesname(db.server)

'the line below is to open it up on the browser…not the doclink

Call rtitem.appendText(“http://” +serName.Common+“/” & Db.filename & “/(DocID)/” & wDoc.UniversalID & “?OpenDocument” )

'Call rtitem.appendDoclink(wDoc,“”)

Call MemoDoc.send(False)

dbserver$ = db.server

Dim dbservername As New notesname(dbserver$)

host$ = dbservername.common

dbpath$ = db.filepath

If Instr(dbpath$,"") <> 0 Then

Mid$(dbpath$,Instr(dbpath$,""),1) = “/”

End If

href$ = “/” & dbpath$ & “/Web Report Processed?OpenPage”

url$ = “http://” & host$ & href$

Msgbox url$

Print “[” & url$ & “]”

Exit Sub

processerror :

Msgbox “Error” & Str(Err) & ": " & Error$,16,“Submit”

Exit Sub

End Sub

I’ve done Prints throughout, and it goes through the entire code. An email notification is sent, but there’s no one in the CC section…I’m stumped!

Subject: RE: How is it not working?

Where are you running this script from? When you run it through the debugger does wDoc actually get set to anything?

brandt

Subject: RE: How is it not working?

I figured out the problem. LotusScript has trouble reading multi value fields that are separated by a new line. I had to set the properties of the field to be seperated by all seperators…thanks for your help.

Subject: RE: How is it not working?

All right. I have to respond to that. This is the sort of conclusion people come to that makes them do awkward and unnecessary workarounds for years thereafter.

LotusScript does not have any problem dealing with multivalue items that have newline as a separator. When LotusScript gets at the field via NotesDocument, delimiters are irrelevant.

What you had there was a field that didn’t really contain multiple values at the point you ran your code, but instead had some delimited string (“A, B, C” as opposed to “A”:“B”:“C”). Changing the field properties made the Notes editing window realize you meant to split the field into multiple values. It has nothing to do with the capabilities of LotusScript, and everything to do with what was actually stored in the field at the time.