Manage Learn to apply best practices and optimize your operations.

Solution To Multiple File Attachments

While searching this Web for a solution to attaching file attachments from the
web to a series of fields in a Notes form
I found that many of you were also finding this difficult,
After spending a time working on this, I now have a solution.

The form I have contains three RTF fields and next to each of these is a File
Upload Control to give the Web user the option to attach files to one, two, or
all of the RTF fields.

The first thing you need to do is to add some javascript to the top of the form
to determine which of the File
Upload controls (if any) the user has selected file for and subsequently grab
the file name from the File Upload control.

The javascript is:
&LTscript language="JavaScript">


function submitDocument() {
form = document.forms[0];

//elements is 12 for first attachment field in my form. You will have to find
out which element number the file upload control
// is on yours as you cxannot reference it with a name,

if(document.forms[0].elements[12].value == ""){
document.forms[0].test1.value = "no";
}
else {
document.forms[0].test1.value = "yes";
document.forms[0].agendas.value = document.forms[0].agendas.value + " FILE
ATTACHMENT: ";
document.forms[0].Subform1.value = document.forms[0].elements[12].value;
}

//the line above is grabbing the file name from the element 12 and putting into
a field on the form called subform1

if(document.forms[0].elements[14].value == ""){
document.forms[0].test2.value = "no";
}
else {
document.forms[0].test2.value = "yes";
document.forms[0].presentations.value = document.forms[0].presentations.value +
" FILE ATTACHMENT: ";
document.forms[0].subform2.value = document.forms[0].elements[14].value;
}


if(document.forms[0].elements[16].value == ""){
document.forms[0].test3.value = "no";
}
else {
document.forms[0].test3.value = "yes";
document.forms[0].minutes.value = document.forms[0].minutes.value + " FILE
ATTACHMENT: ";
document.forms[0].subform3.value = document.forms[0].elements[16].value;
}

this.form.submit();
}



</script>

You will also need the following HTML to create the submit button that will run
the above code when pressed.

&LTinput type="button" value="submit" onClick="submitDocument()">

THEN:

You need to run a web query agent that will grab the file from the filenames
put into the fields subform1, subform2, subform3
and use the filenames to grab the files out of the $file fields and put them
into the relvant RTF fields.

The Lotusscript for the agent is as follows:

Dim session As New NotesSession
Dim doc As NotesDocument
Dim db As NotesDatabase
Dim minutes As String

Dim v2File As NotesItem


Dim inputAttach As NotesEmbeddedObject
Dim inputattach2 As notesembeddedobject
Dim rtitem As NotesRichTextItem
Dim rtitem2 As notesrichtextitem
Dim stuart As NotesRichTextItem
Dim newValues( 0 To 100 ) As String

Set db = session.CurrentDatabase
Set doc = session.DocumentContext


'this is grabbing the file details and trimming it so that we loose the
original path and are left with just the filename
adjust = doc.getitemvalue ("Subform1")
adjust2$ = adjust(0)
v1 = Strrightback(adjust2$, "\")

adjust3 = doc.getitemvalue ("subform2")
adjust4$ = adjust3(0)
v2 = Strrightback(adjust4$, "\")

adjust5 = doc.getitemvalue ("subform3")
adjust6$ = adjust5(0)
v3 = Strrightback(adjust6$, "\")
'SModul is the name of the target NotesRichTextItem
If doc.HasEmbedded Then



' On Error Goto ProcessError
' Get the v2 attachment into a NotesEmbeddedObject and extract it
' to the Notes data directory
count = 0


'choosing which files to attach
Dim datadir As String, filename As String, FilePath As String

datadir$ = session.GetEnvironmentString("Directory", True)
If v1 <> "" Then

filename$ = v1
Set inputAttach = doc.GetAttachment(filename$)

FilePath$ = datadir$ + "\" + filename$

Call inputAttach.ExtractFile(FilePath$)


' Create the rich text item and re-attach the file


Set rtitem = doc.getfirstitem("agendas")
Set inputAttach = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", FilePath$)

End If


If v2 <> "" Then

filename$ = v2
Set inputAttach = doc.GetAttachment(filename$)

FilePath$ = datadir$ + "\" + filename$

Call inputAttach.ExtractFile(FilePath$)


' Create the rich text item and re-attach the file


Dig Deeper on Domino Resources - Part 5

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close