LotusScript for closing dialog boxes

Hi,

I am new to Notes, and I was wondering if there is any easy LotusScript code for closing dialog boxes. I know it can be done in Formula with @Command[CloseWindow], but I need to be able to do it in LotusScript.

Here is the code if it helps at all.

Sub Click(Source As Button)

Const sStartDateTime = "03/07/2009 16:30:00"

Const sLocation = "My Workspace"

Const sSubject = "Green Team Reminder"

Const sSendTo = "Daffy Duck/"

Const sMessage = "A reminder to shut the blinds, turn off your monitor, and be green for the weekend."



Dim Session As NotesSession

Dim Workspace As NotesUIWorkspace

Dim dbMail As NotesDatabase

Dim docMail As NotesDocument

Dim vMailAddress As Variant

Dim dtStart As NotesDateTime, dtEnd As NotesDateTime, dtNow As NotesDateTime

Dim drAppointment As NotesDateRange

Dim uiAppointment As NotesUIDocument



Dim vFreeTime As Variant

Dim bContinue As Boolean



Set Session = New NotesSession



Set dtNow = New NotesDateTime("")

dtNow.SetNow



Set dtStart = New NotesDateTime(sStartDateTime)



bContinue = True







If bContinue Then

	Set Workspace = New NotesUIWorkspace

	Set dbMail = New NotesDatabase("", "")

	

	vMailAddress = Evaluate("@MailDBName")

	Dim doc As NotesDocument

	If dbMail.OpenWithFailover(vMailAddress(0), vMailAddress(1)) Then

		Set uiAppointment = Workspace.ComposeDocument(vMailAddress(0), vMailAddress(1), "Appointment")

		With uiAppointment

				' note that this might be Notes 8 specific

				' Notes 6 might need to retain AppointmentType field setting

			.FieldSetText "tmpAppointmentType", "4"

			' Notes 6 original setting

			'	.FieldSetText "AppointmentType", "4"

			.FieldSetText "Subject", sSubject

			.FieldSetText "Location", sLocation

			.FieldSetText "StartDate", dtStart.DateOnly

			.FieldSetText "StartTime", dtStart.TimeOnly			

			.GotoField "Body"

			.FieldSetText "Body", sMessage + Chr$(10)				

			

		End With

		

		

		Set doc = uiAppointment.Document

			' ---> changes made here

			' these fields must be set for the appointment to display in the correct place

		

		doc.ReplaceItemValue  "CalendarDateTime", dtStart

		doc.ReplaceItemValue  "StartDateTime", dtStart

		doc.ReplaceItemValue  "Repeats", "1"

		Set dtEnd = dtStart

		Call dtEnd.AdjustYear(10)

		doc.ReplaceItemValue "RepeatInterval", "7"

		doc.ReplaceItemValue "RepeatHow", "U"

		doc.ReplaceItemValue "RepeatUntil", dtEnd

		doc.ReplaceItemValue "$Alarm", 1

		

		

		uiAppointment.Refresh

		uiAppointment.Save

		uiAppointment.Close

		

		

		Set uiAppointment = Nothing

		

		Set docMail = New NotesDocument(dbMail)

		With docMail

			.ReplaceItemValue "Form", "Memo"

			.ReplaceItemValue "Subject", Session.CommonUserName + " has pressed the  """ + sSubject + """  buton "

			.ReplaceItemValue "SendTo", sSendTo

			.Send False

		End With

		Delete docMail

	Else

		Messagebox "Unable to locate mail database", 48

	End If

	

	Set dbMail = Nothing

	Erase vMailAddress

	Set Workspace = Nothing

End If

Delete dtStart

Set Session = Nothing

End Sub

Basically, I am trying to code a button which will enter a repeating entry into people’s calendars. The trouble is, the code opens the Repeating Entry and Alarm dialog boxes, and I don’t want users to have to keeping clicking “Ok”.

Thanks.

Subject: You can create the back-end documents directly.

You don’t have to go through the UI. Create a document manually that’s similar to the one you want, then use the NotesDocument/NotesItem classes to create similar documents. Note that repeating entries use multiple documents. The DupliDoc tool will help you by generating LS source to duplicate a document.

Subject: Re:

Not sure I follow you. I thought I was going through the backend?

Set doc = uiAppointment.Document

				

		doc.ReplaceItemValue  "CalendarDateTime", dtStart

		doc.ReplaceItemValue  "StartDateTime", dtStart

		doc.ReplaceItemValue  "Repeats", "1"

And I’m not quite sure what you mean by creating a document manually. I’m trying to create a button, which will create calendar entries without the user having to do anything other than press the button.

Subject: No, when you use ComposeDocument method you’re using the front end.

Instead, use CreateDocument. There’s no need to use any method of NotesUIWorkspace.

Create a calendar entry manually to see what fields are in it and then write code to duplicate those fields using NotesDocument.