Convert Calendar Accept Action in to an Agent?

Hi there,

Is there any way that I can get the Accept button in the standard Notes mail file (for accepting Calendar invitations) to run as an agent? I’ve tried but I just get a “Variable Not Set” error on the server when it runs. This is the only way that I’ve been able to think of that will automatically accept calendar invitations even if there’s a conflict.

The script is below, if anyone can help - I owe you pleny of beers if you’re ever in London!!

Thanks,

Alex

Sub Click(Source As Button)

' this action will formally accept the meeting - ie. Book BusyTime.

' it is available for users who Tentatively Accepted the meeting, but now want to formally accept it.

%REM

Dim uidoc As NotesUIDocument

Dim note As notesdocument

Dim nResult As Integer



Set uidoc = csEventObj.UIDocument     

Set note = uidoc.Document



If Not(uidoc.editmode) Then uidoc.editmode = True		

Call uidoc.Fieldsettext("BookFreeTime", "0")

Call csEventObj.m_beobject.UpdateBusyTimeInfo(True)

Call uidoc.save

Call uidoc.close

%END REM

' Revised to do the Full Accept Action ( message back to Chair, etc. )

Dim uidoc As NotesUIDocument

Dim nResult As Integer

Dim noteInEditor As notesdocument



Set uidoc = csEventObj.UIDocument     

Set noteineditor = cseventobj.m_ws.currentdocument.document



If (csEventObj.OkToAccept(False)) Then

	' Update information project code below this line

	

	If Not(uidoc.editmode) Then uidoc.editmode = True

' if this item exists on the main document, then there is a conflict

	Const CONFLICT_TITLE = "Conflicting Information"

	Dim ws As New notesuiworkspace

	Dim vConflicts As Variant

	Dim s As New Notessession

	'Dim bUIEnable As Integer	

	'bUIEnable = s.GetEnvironmentvalue("CS_ENABLE_ITEM_SEQ",True) 

	

	'If bUIEnable Then 

	Call uidoc.Fieldsettext("BookFreeTime", "0")

	

	vConflicts = cseventobj.m_beobject.GetConflictingItems()      ' need to test real code for single conflict (do I still get an array back????)

	'End If

	

	If Isarray( vConflicts ) Then

		Dim ub1 As Integer

		Dim str1 As String

		Dim x As Integer

		Dim ConfList As String

		Dim tmpSNDT As NotesDateTime

		Dim tmpENDT As NotesDateTime

		

		ub1 = Cint(Ubound(vConflicts ,1)  ) ' this will always be Zero for non-repeating

		Redim cLst (ub1) As String

		

		For x = 0 To ub1	

			cLst (x) = Cstr(vConflicts(x,4) )

			cLst(x) = Replace( cLst(x) , "Body" , "Description") 

			cLst(x) = Replace( cLst(x) , ":" , ", ") 

			Set tmpSNDT= New NotesDateTime ( Cstr(vConflicts(x,1) ) )			

			Set tmpENDT= New NotesDateTime ( Cstr(vConflicts(x,3) ) )			

			ConfList = ConfList + tmpSNDT.LocalTime + "          " + tmpENDT.LocalTime + "          " + cLst(x) + Chr(13)

		Next 

		

		Call noteInEditor.ReplaceItemValue("ConfList", ConfList)

’ ( formname, autohorzfit, autovertfit, nocancel, nonewfields, nofieldupdate, readonly, title, notesdocument, sizetotable, nookcancel)

		Call ws.Dialogbox ("(UpdateInfoConflict)",True,True,True,False,False,False,CONFLICT_TITLE, noteInEditor , True,True,False)

		Select Case	noteinEditor.GetItemValue("dlgAction")(0)

		Case "YES":

			'Call s.SetEnvironmentVar( "$CS_OVERWRITE_CONFLICTS", "1")  

			CSEventObj.m_UpdateInfoOverWrite = CS_UI_OVERWRITE

		Case "NO":

			'Call s.SetEnvironmentVar( "$CS_OVERWRITE_CONFLICTS" , "")

			CSEventObj.m_UpdateInfoOverWrite = CS_UI_NOOVERWRITE

		Case "CANCEL":

			Exit Sub

		End Select

		

		Call uidoc.save

		

	Else   ' There are no conflicts, so just continue with UpdateCalendar action

		Call uidoc.save

	End If

	

' Update information project code above this line'

	

	Call uidoc.close 

End If	

End Sub

Subject: Convert Calendar Accept Action in to an Agent?

Hello AlexErrors in scheduled agent most probably depend on usage of UI classes (notesuiworkspace, notesuidocument).

I have tryed to do similar things as you do, and I would recommend to use “Accept” button used in web-version of “Appointment” form instead of using button from Notes-version of form. Web version does not use UI classes which makes it much easier to modify for running in background. Modifying button into agent is not enough, you will need to modify script libraries too.

If you do not want to send notification of meeting/invitation acceptance to original sender, then you can manually set all neccessary field on the document and it will show in user’s calendar as “real” meeting.