Attachments - incorrectly attaching

I have a process in place to Update attachments with multiple versions to a particular PO number.

Example 3750_1 and 3750_2 and 3750_3 etc. But, 13750_1, also attach to document 3750 when agent is processed. I need to find away to only allow docs with same PO to attach to the specific document. My code is shown below. Any and all help will be greatly appreciated. Thanks in advsance

Sub UpdateAttachments

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject

Dim attachpath As String

Dim basepath As String

Dim temppath As String

Dim fileName$

Dim fileExists As Variant



 'Stop

Set rtitem = ldoc.getfirstitem("SR_AttachedQuote")

temppath = "E:\temp\" 'change to e drive for server

’ temppath = "C:\temp" 'change to c drive for server

basepath = {\\wolf\ftp\User_Uploads\}

'basepath = "c:\OraOrder\" 

’ attachpath = basepath & {gbl_svc_po_rec_} & recIn.varPOnum & {}

attachpath = basepath & {gbl_svc_po_rec_*} &  recIn.varPOnum & {.pdf}

fileName$ = Dir$(attachpath, 0)

Do While fileName$ <> ""

	fileExists = False

	If rtitem.text <> "" Then  'condition added 11.2.06 by jcc to correct for helpdesk 2006-45148

		Forall x In rtitem.Embeddedobjects

			If fileName$ = x.name Then

				fileExists = True

			End If

		End Forall

	End If

	If Not(fileExists) Then

		Filecopy basepath & fileName$, temppath & filename$

		Set object = rtitem.EmbedObject _

		( EMBED_ATTACHMENT, "",temppath & filename$, temppath & filename$)

		HasChanged = True

		Kill temppath & filename$

	End If

	Kill basepath & fileName$

	fileName$ = Dir$()

Loop

Set rtitem = Nothing

End Sub

Subject: Attachments - incorrectly attaching

basepath = {\\wolf\ftp\User_Uploads\}

attachpath = basepath & {gbl_svc_po_rec_*} &  recIn.varPOnum & {.pdf}

Would mean you’re looking for

\\wolf\ftp\User_Uploads\gbl_svc_po_rec_*3750.pdf

Don’t you want?

\\wolf\ftp\User_Uploads\gbl_svc_po_rec_3750*.pdf

or

\\wolf\ftp\User_Uploads\gbl_svc_po_rec_3750_*.pdf

Subject: RE: Attachments - incorrectly attaching

No, actually I need to allow for 4 & 5 digit po’s and versions of a specific PO and 3750 and 13750 (both with versions - see below)

Version example

\wolf\ftp\User_Uploads\gbl_svc_po_rec_1_3750.pdf

\wolf\ftp\User_Uploads\gbl_svc_po_rec_2_3750.pdf (etc)

               AND

\wolf\ftp\User_Uploads\gbl_svc_po_rec_1_13750.pdf

\wolf\ftp\User_Uploads\gbl_svc_po_rec_2_13750.pdf (etc)

Thanks in advance

Subject: RE: Attachments - incorrectly attaching

Sorry Mary, I’m now confused… So you want all these attached? I thought you did NOT want the second set after the “AND” (the ones with the 13750).

\wolf\ftp\User_Uploads\gbl_svc_po_rec_1_3750.pdf

\wolf\ftp\User_Uploads\gbl_svc_po_rec_2_3750.pdf (etc)

               AND

\wolf\ftp\User_Uploads\gbl_svc_po_rec_1_13750.pdf

\wolf\ftp\User_Uploads\gbl_svc_po_rec_2_13750.pdf (etc)

I would expect the following would include all of the above?

\wolf\ftp\User_Uploads\gbl_svc_po_rec_*3750.pdf

If you just wanted the ones above the AND I would issue:

\wolf\ftp\User_Uploads\gbl_svc_po_rec_*_3750.pdf

If you knew it was only 1 digit, ie you never had more than 9 you could try:

\wolf\ftp\User_Uploads\gbl_svc_po_rec_?_3750.pdf

Subject: Attachments - incorrectly attaching

How/Where are you getting ldoc? if the file is attaching to the wrong document the problems lies in how you are selecting the doc

Subject: RE: Attachments - incorrectly attaching

ldoc is found by looking at a specific PO in the view and it shows fine when I look thru the debugger.

I think the problem is in this line of code in the Sub UPdateAttachment by the * wildcard for different versions of the same PO #, but I can’t seem to prevent it.

attachpath = basepath & {gbl_svc_po_rec_*} & recIn.varPOnum & {.pdf}

===========================================

Function FindExistingPO(varPONumber As Variant) As Variant

Dim strAction As String

On Error Goto errHandle

FindExistingPO = False



strErrorMsg = "Working with Po Number: " + Trim$(Cstr(varPONumber))

If lview Is Nothing Then Set lview = ldb.getview("ByPONum")

Set ldoc = lview.getdocumentbykey(varPONumber)

If ldoc Is Nothing Then

	FindExistingPO = False		

	'SendNotice True

Else

	FindExistingPO = True

End If

Exit Function

errHandle:

FindExistingPO = False

Exit Function     

End Function