Subject: RE: Post Open Event Issue
Ok,
The button that begins the process calls this function:
(DIMs removed to save space)
Sub planAttachment_start(attachmentType As String)
If uidoc.EditMode = False Then
uidoc.EditMode = True
End If
If attachmentType = "ptcsd" Then
Call ws.DialogBox("Dialog - attachmentMethod",True,True,True,True,False,False,"Plan Information")
If capaDoc.attachmentMethod_diag(0) = "" Then
Goto fileAttach
End If
Forall values In capaDoc.attachmentMethod_diag
i = Cint(values)
valueTotal = valueTotal+i
End Forall
End If
fileAttach:
files = ws.OpenFileDialog(False, "File List", "*.*", "C:\")
If Isempty(files) = True Then
Error 556, "Attachment failed."+Chr$(13)+Chr$(13)+"No file was selected."
Else
title = ws.Prompt(PROMPT_OKCANCELEDIT, "Plan Title", "Enter a title for this attachment.")
If title = "" Then
Error 556, "Attachment failed."+Chr$(13)+Chr$(13)+"The attachment title is required."
End If
If attachmentType = "other" Then
Call ws.DialogBox("Dialog - otherAttachment",True,True,True,True,False,False,"Other Attachment Details")
End If
Call addAttachment(capaDoc, attachmentType, title, files)
Call updateAttachmentFields(capaDoc, valueTotal, attachmentType)
capaDoc.Save True, False, False
capaDoc.saveOptions="0"
uidoc.editmode = False
End If
Goto finish
errorHandle:
Msgbox Error$, MB_OK + MB_ICONSTOP, "Error"
Resume finish
finish:
End Sub
The called primary sub is here:
Sub addAttachment(doc As NotesDocument, attachmentType As String, title As Variant, files As Variant)
Call setSessionAndDb(sess, db, ws, uidoc, doc)
Dim attachmentDoc As New NotesDocument(db)
Dim object As NotesEmbeddedObject
attachmentDoc.form = "Attachment Record"
Dim rtItem As Variant
Dim otherDescription As String
Set rtItem = New NotesRichTextItem(attachmentDoc, "attachment")
If Isempty(files)Then
Exit Sub
End If
pathString = Cstr(files(0))
Set object = rtItem.EmbedObject(EMBED_ATTACHMENT, "CAPA Plan", pathString)
If doc.form(0) <> "EV" Then
attachmentDoc.capaNumber = doc.number(0)
Else
attachmentDoc.capaNumber = doc.capanumber(0)
End If
attachmentDoc.attachmentName = object.Name
attachmentDoc.attachmentTitle = title
attachmentDoc.attachedBy = sess.userName
attachmentDoc.unid_Capa = doc.unid_capa(0)
If attachmentType = "other" Then
Call getOtherType(db,Cstr(doc.number(0)), otherDescription)
attachmentDoc.relatedCapaItem = otherDescription
Else
attachmentDoc.relatedCapaItem = getRelatedItemLabel(attachmentType)
End If
attachmentDoc.Save True, False, False
End Sub
The other subs called are very simple mainly just used for setting field values.
Thanks