Prompts and Arrays

I have a button in a form that I want to be able to choose one or more clients to create another form for. The problem is for each client I want to create multiple copies of the target form (Recurring event) based on the event type. Hope this makes sense. What I get is Type Mismatch when the PROMPT box comes up. What am I missing? Any help is appreciated. The code is below:

Sub Click(Source As Button)

Dim Session As New NotesSession

Dim Workspace As New NotesUIWorkspace

Dim db_Current As NotesDatabase

Dim Doc_Client As NotesDocument

Dim Doc_Event As NotesDocument

Dim DC_Client As NotesDocumentCollection

Dim Event_Type As Variant

Dim Event_List(0 To 8) As Variant



Event_List(0)="PM Audit"

Event_List(1)="Client Survey"

Event_List(2)="Account Review"

Event_List(3)="Technology Planning"

Event_List(4)="SLA - Client Service Plan"

Event_List(5)="RSM - Client Service Plan"

Event_List(6)="HSHS - Client Service Plan"

Event_List(7)="Website and E-mail Hosting - Client Service Plan"

Event_List(8)="Security Assessment - Client Service Plan"



Dim Client_List( ) As String



Set db_Current = Session.CurrentDatabase



Set DC_Client = Workspace.PickListCollection( 1 ,True , "mercury/Walker", "ClientServices\CLIENT95.nsf", "Contract Type" , "Client List" , "Select Client names to create Recurring event for" )



If DC_Client.Count < 1 Then Exit Sub



Redim Client_List( 1 To DC_Client.Count )

Event_Type = Workspace.Prompt(PROMPT_OKCANCELLISTMULT,"Enter the Event Type", "Event", "", Event_List)



For i = 1 To DC_Client.Count

	

	Set Doc_Event = New NotesDocument( db_Current )

	Set Doc_Client = DC_Client.GetNthDocument( i )

	If Event_Type >1 Then

		Forall e In Event_Type

			Doc_Event.Form = "Recurring Event" ' Put the form name for the recurring event document here

			Doc_Event.Event = e

		End Forall

	End If

’ Replace the name of the actual client name field on the right hand side of the statement.

	Client_List( i ) = Doc_Client.CompanyName( 0 ) 

’ Example of assigning values to the event form. Replace field names accordingly

	Doc_Event.CompanyName = Doc_Client.CompanyName( 0 )

	Doc_Event.ClientCode = Doc_Client.ClientCode(0)

	Doc_Event.ClientManager = Doc_Client.ClientManager(0)

	Doc_Event.TSM = Doc_Client.TSM(0)

’ Save the event document

	Call workspace.EditDocument(True,Doc_Event)

	Call workspace.CurrentDocument.Refresh

	Call workspace.CurrentDocument.Gotofield("Reason")				

	

Next

Subject: Prompts and Arrays

Try leaving out the empty string for the default and instead leaving that parameter blank as that it is optional.

Event_Type = Workspace.Prompt(PROMPT_OKCANCELLISTMULT,“Enter the Event Type”, “Event”, , Event_List)

Subject: RE: Prompts and Arrays

I tried that and I get an error “Cannot locate default form”.

Any other ideas?

Subject: RE: Prompts and Arrays

Use the Notes debugger to step thru the code and find out what line the error is actually occurring on. I suspect now it’s on the EditDocument call, because you’ve never set the Form field of doc_Event.

It looks like you’re trying to create more documents inside that loop, but you can’t create new documents by just repeatedly assigning fields of the same NotesDocument object. If your loop was executing at all, all you’d be doing is overwriting the contents of those fields each time thru the loop. You need to create a new NotesDocument object for each document you create.

However, in this case I don’t think it’s the best plan to create and save a bunch of documents associated with the new document the user is about to start editing, because the user might never save the document; then you’d be stuck with a bunch of associated documents that are associated with something that doesn’t exist. Wait to create your recurring instance documents until the Postsave event on the main form.

Subject: Prompts and Arrays

The error is due to the form field never being set.

You compare Event_Type to an integer (1). Event_Type is a string array, so it will always evaluate to false.

Try changing

If Event_Type >1 Then

Forall e In Event_Type

Doc_Event.Form = “Recurring Event” ’ Put the form name for the recurring event document here

Doc_Event.Event = e

End Forall

End If

… to…

If isEmpty(Event_Type) then end ’ exit if user pressed Cancel

Doc_Event.Form = “Recurring Event” ’ Put the form name for the recurring event document here

Doc_Event.Event = Event_Type ’ sets the Event field to values stored in Event_Type array

Subject: RE: Prompts and Arrays

I no longer get the error, but all choices are now in the field in one document. What I need is a new document (recurring event) for each value chosen. If 3 choices are made, I need 3 recurring events. How do I do that?

Subject: RE: Prompts and Arrays

I don’t get what you try to achieve.

Try debugging a little yourself, with the debugger enabled.

If you get stuck, try to re-post what you are actually trying to achieve (in details), what you get, along with the code.