Hello Everybody,
I have a webquerysave agent which is working fine. One of the things my agent is doing is, removing the selected files. Now I can have upto 50 files and do not want to write that function 50 times. My agent is:
Dim Session As New NotesSession
Dim db As NotesDatabase
Set db=Session.CurrentDatabase
Dim thisdoc As NotesDocument
Set thisdoc=Session.DocumentContext
Dim statusval As String
Dim prognamval As String
Dim profileview As NotesView
Set profileview=db.getview("Profile")
Dim profiledoc As NotesDocument
Set profiledoc=profileview.getfirstdocument
Dim urlpath As String
urlpath=profiledoc.AgentsPath(0)
statusval=thisdoc.StatusHidden(0)
prognamval=thisdoc.ProgName(0)
thisdoc.Status=statusval
Dim dfile As String
Dim file As String
’ Deleting Function. I dont want this to repeat 50 times. I need help here
dfile=thisdoc.DeleteFile1(0)
If dfile<>"" Then
file=thisdoc.FileAttachmentQ1(0)
file=Strrightback(file,"\")
Call thisdoc.RemoveItem(file)
thisdoc.DeleteFile1=""
thisdoc.FileAttachmentQ1=""
End If
dfile=""
file = ""
'End deleting function
’ The part below works fine
If (statusval<>"Completed") Then
url = "[" & urlpath & "/Surveydetailedcontent/" & prognamval & "?editdocument"
Print url & "]"
Else
url = "[" & urlpath & "/SurveyThanks?openform"
Print url & "]"
End If
Where DeleteFile1 is the checkbox field which when selected should delete the file. I also have FileAttachmentq1 field which is used for giving url to the attached file. This is all working great. Now my users want to have 50 of the DeleteFiles fields in front of each attachment. In order to delete those I will have to write the above script 50 times. I have never written any sub functions. I tried something like this
'I need to fix this. Call it properly and have the right code
Call remFiles(thisdoc.DeleteFile1(0),thisdoc.FileAttachmentQ1(0), thisdoc) As String
Public Function remFiles(dfile As String, fileattachment As String, thisdoc As NotesDocument) As String
If dfile<>"" Then
file=Strrightback(file,"\")
Call thisdoc.RemoveItem(file)
thisdoc.dfile=""
thisdoc.fileattachment=""
End If
End Function
But this is not working. Can anybody help me with this. Also for this to work, what do I need to declare under Options or Declarations.
Thank you for all your help.
Ki.