Assigning an array to a field

Hi all,

I’m walking a view and collecting names to put into a calendar invitation. Even if I hard-code the names, I still can’t get the “RequiredAttendees” field to be populated. I keep getting a “Subscript out of range” error. Now I’m not even sure if that’s the field I want, but assuming it is, how can I change my script so it will work?

Here’s what I currently have (Option Declare is turned on and everything is dimmed):

Dim mailDB As New NotesDatabase( “”, “” )

Call mailDB.OpenMail

'new calendar invitation

CalList(0) = “Jane Doe/ACME”

CalList(1) = “John Doe/ACME”

Set CalDoc = New NotesDocument( mailDB )

CalDoc.Form = “Appointment”

Call session.SetEnvironmentVar(“CSDocType”, “3”)

CalDoc.tmpRequired = CalList() <== This is where the error is

Set CalUIDoc = uiws.EditDocument( True, CalDoc )

Many thanks for all available help.

MaryJane Johnson.

Subject: Assigning an array to a field

Dim mailDB As New NotesDatabase( “”, “” )Call mailDB.OpenMail 'new calendar invitation

CalList(0) = “Jane Doe/ACME”

CalList(1) = “John Doe/ACME”

Set CalDoc = New NotesDocument( mailDB )

CalDoc.Form = “Appointment”

Call session.SetEnvironmentVar(“CSDocType”, “3”)

dim calItem as NotesItem

Set calItem = New NotesItem(

caldoc, “tmpRequired”, CalList )

Set CalUIDoc = uiws.EditDocument( True, CalDoc )

Subject: RE: Assigning an array to a field

Thank you very much, FS, that opens up a new invitation correctly, however the “Invite:” field is blank. I tried using “REQUIREDATTENDEES” too as that’s where the names are in an invitation that’s been received, but still no joy. :frowning:

How can I get the “Invite:” field populated on the screen so the invitations go to those people? I know I’ll get much grief if the names are there, but hidden, as users don’t generally like to believe developers. :wink:

Many thanks,

MaryJane Johnson.

Subject: RE: Assigning an array to a field

Aside from the notion that there really are many more fields you really should populate, the answer to your question is:

CalDoc.SendTo

CalDoc.EnterSendTo

Subject: RE: Assigning an array to a field

That’s it! They’re in there, thank you!

I know I’ve been a pain with this, but what other fields should I be populating? I’ve taken a peek at the QueryOpen and PostOpen and to be honest, they’re not making an awful lot of sense to me. :frowning:

Many thanks again,

MaryJane Johnson.

Subject: RE: Assigning an array to a field

Take a look at the document properties for both a document created manually and one created via your script (without opening it). It will show you the field differences and the values that should be in there. This saves you having to open and save the documents manually to get them to compute.

Here is what I do to create a reminder via an agent (this creates a reminder and sets the notification alarm to trigger one day before scheduled. May be overkill, but I feel better about it):

Set doc2 = dbMail.createdocument

doc2.Form = “Appointment”

doc2.From = strUser

doc2.Chair = strUser

doc2.AltChair = strUser

doc2.Principal = strUser

doc2.AppointmentType = “4”

doc2.Subject = strSubject

doc2.Categories = strCategory

doc2.ScheduleSwitcher = “1”

doc2.OrgTable=“C0”

doc2.StartDateTime =Cdat(apptdatetime)

doc2.StartDate = Cdat(appt_date)

doc2.EndDateTime = Cdat(apptenddatetime)

doc2.EndDate = Cdat(appt_date)

doc2.StartTime = Cdat(appt_time)

doc2.EndTime = Cdat(appt_time)

doc2.~_ViewIcon = 10

doc2.CalendarDateTime = Cdat(apptdatetime)

Dim rtNote As NotesRichTextItem

set rtNote = New NotesRichTextItem (

doc2, “Body” )

Call rtNote.AppendText( “Click here to go to the reference document==>>” )

Call rtNote.AddTab( 1 )

Call rtNote.AppendDocLink (doc,“”)

Dim stringArray ( 1 To 2 ) As String

stringArray( 1 ) = “D”

stringArray( 2 ) = “A”

Call doc2.AppendItemValue

(“ExcludeFromView”,stringArray)

doc2.SequenceNum = 1

Call doc2.AppendItemValue(“$PublicAccess”,“1”)

Call doc2.AppendItemValue(“$Alarm”, 1)

Call doc2.AppendItemValue(“$AlarmDescription”,

strSubject)

Call doc2.AppendItemValue

(“$AlarmMemoOptions”, “2”)

Call doc2.AppendItemValue(“$AlarmOffset”, -1440)Call doc2.AppendItemValue(“$AlarmSendTo”,

strUser)

Call doc2.AppendItemValue

(“$AlarmSound”, “chord”)

Call doc2.AppendItemValue(“$AlarmUnit”, “D”)

Call doc2.AppendItemValue(“$AltPrincipal”,

strUser)

Call doc2.AppendItemValue(“Alarms”, “1”)

Call doc2.AppendItemValue

(“$BorderColor”, “D2DCDC”)

Call doc2.AppendItemValue(“$CSVersion”, “2”)

Dim strCSWISL (0 To 4) As String

strCSWISL(0)=“$S:1”

strCSWISL(1)=“$L:1”

strCSWISL(2)=“$B:1”

strCSWISL(3)=“$R:1”

strCSWISL(4)=“$E:1”

Dim itemCSWISL As NotesItem

Set itemCSWISL = New NotesItem (

doc2, “$CSWISL”, strCSWISL )

Call doc2.AppendItemValue(“$ExpandGroups”, “3”)

Call doc2.AppendItemValue

(“$FromPreferredLanguage”, “en-US”)

Call doc2.AppendItemValue(“$HFFlags”, “1”)

Call doc2.AppendItemValue(“$LangChair”, “”)

Call doc2.AppendItemValue(“$NoPurge”, Cdat

(apptdatetime))

Call doc2.AppendItemValue

(“$SMTPKeepNotesItem”, “1”)

Dim strWatched (0 To 4) As String

strWatched(0)=“$S”

strWatched(1)=“$L”

strWatched(2)=“$B”

strWatched(3)=“$R”

strWatched(4)=“$E”

Call doc2.AppendItemValue(“$WatchedItems”,

strWatched)

Call doc2.AppendItemValue(“$BusyName”, “”)

Call doc2.save(True,False)

Call doc2.PutInFolder(“$Alarms”, True)

Subject: RE: Assigning an array to a field

Thank you very much for all this. I am in your debt and will plough through this and tailor it to my needs, thanks again!!

MaryJane Johnson.

Subject: Oh and to those that wonder why…

I did not just use doc.ComputeWithForm, it just would not work because this method would throw a validation error and not save when I tried it that way.

Subject: Just take off the Parens: CalDoc.tmpRequired = CalList

Subject: RE: Just take off the Parens: CalDoc.tmpRequired = CalList

Bill, thanks for your response. Unfortunately nothing shows up, though at least there’s no error :slight_smile:

Many thanks,

MaryJane Johnson.