Is there any reason that this code should take 30-35 seconds to execute on the client? I’m pretty new at LotusScript and suspect that I have some poor coding in here. This button is on a doc that copies (and negates) specific fields to a new doc, saves the new doc, closes the UI doc, refreshes the current view, and then refreshes a view used for a DB lookup.
Sub Click(Source As Button)
'Action to copy current document reversing the hours requested entries,
'submitting to supervisor, and effectively cancelling request
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim doc2 As NotesDocument
Dim success As Variant
Set db = session.CurrentDatabase
Set view = db.GetView("CheckDupCancel")
'Get document, copy, change fields, then leave in Edit mode so staff can review and submit or CANCEL
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Set doc2 = New NotesDocument (db)
Call doc.CopyAllItems (doc2, True )
'Set fields to new values
Dim sick,ppd,ipp,vac,hol,per As Variant
Dim negate As Integer
Dim Rev As String
negate = (-1)
sick=negate * doc2.SickDays(0)
ppd = negate * doc2.PPDdays(0)
ipp = negate * doc2.IPPdays(0)
vac= negate * doc2.VacDays(0)
hol = negate * doc2.HolidayDays(0)
per = negate * doc2.PersonalDays(0)
oth= negate * doc2.OtherDays(0)
Rev=doc2.ReviewerLog(0)
Set notesItem = doc2.ReplaceItemValue("SickDays", sick)
Set notesItem = doc2.ReplaceItemValue("PPDdays", ppd)
Set notesItem = doc2.ReplaceItemValue("IPPdays", ipp)
Set notesItem = doc2.ReplaceItemValue("VacDays", vac)
Set notesItem = doc2.ReplaceItemValue("HolidayDays", hol)
Set notesItem = doc2.ReplaceItemValue("PersonalDays", per)
Set notesItem = doc2.ReplaceItemValue("OtherDays", per)
Set notesItem = doc2.ReplaceItemValue("Form", "Cancel")
Set notesItem = doc2.ReplaceItemValue("Approved", "")
Set notesItem = doc2.ReplaceItemValue("Comment", "")
Set notesItem = doc2.ReplaceItemValue("dspApproved", "")
Set notesItem = doc2.ReplaceItemValue("dspComments", "")
Set notesItem = doc2.ReplaceItemValue("ReviewerLog", Rev)
Set notesItem = doc2.ReplaceItemValue("Status", 1)
Set notesItem = doc2.ReplaceItemValue("CurrentEditor",doc2.ReviewerList)
doc2.RemoveItem("SaveOptions")
doc2.RemoveItem("CurrentUser")
doc2.RemoveItem("SubmitNow")
doc2.RemoveItem("NSubmitNow")
doc2.RemoveItem("Resubmit")
doc2.RemoveItem("SendError")
doc2.RemoveItem("WebCategories")
success = doc2.ComputeWithForm( False, False )
If success Then
Call doc2.Save( True, True )
End If
’ Call doc2.Save (False, False) 'Save new doc
Call uidoc.Close(True)
Call workspace.ViewRefresh
Messagebox ("Your supervisor has been notified that this Cancellation requires review. If approved by your supervisor, this request will be cancelled. It will still appear in your records, but the hours will be added back to your total.")
Call view.Refresh
End Sub