Post Open Event Issue

I hope this doesn’t come across to complicated.

I have a form that has code in the post open event.

On that form is a button. Clicking that button fires off an agent of one line. Its a @tools([run]} which in turn calls a library with code execute.

Part of the process toggles the edit mode but a no time do I close the document I originally called the agent from. I do work with some other documents during the course of the agent’s running. These documents are only accessed/created via the backend, with the exception of a ws.dialogbox call from which I save a document on the back end via the query close of the form.

Any how, when the agent routine finishes up, the original document does a post open, running code there. I’d prefer this not to occur.

I can provide code if you’d like to have a look.

I hope someone has an idea on this.

TIA

Dave

Subject: Post Open Event Issue

please post your code.

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

Subject: RE: Post Open Event Issue

I don’t see anything out of the ordinary. Are you saying you open a doc, postopen runs, you press a button on the doc and postopen runs again after your button script runs? Have you tried running in debug mode to see at what point the second post open occurs?