SearchDomino.com
August 27, 2001
Developer Tip
================================================= 
------------------------------------------------- 
Sponsored By: THE VIEW Domino Developers Conference
------------------------------------------------- 
At this must-attend event for Domino Developers, you get in-depth
instruction and hands-on training to build on your existing skills,
take advantage of the hottest technologies, and dive into the latest
advances in Domino development. World-class experts like Debbie Lynd,
Bob Balaban, Tony Higham and Kevin Marshall deliver hard-core
programming techniques you can put to use right away to solve your
toughest development challenges! Visit http://www.eVIEW.com/domdev
for more information and to save $200 when you register today!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
Feature Tip
================================================= 
Title: Insert various file attachments on the Web

This tip was submitted by Nicolas Cretet, an analyst and developer in
Barcelona, Spain.

This tip allows you to insert various files in a document and refresh
it for each upload in a Web application.

All the files will be inserted in a Rich Text Field that is named
"RTFiles".

The name of the database is "NameBase.nsf"

CODE: 

You need two forms and a view:

- The first form is the default form used by the document (Name =
DefaultForm).
- The second form is used to insert the files (Name = InsertForm).
- A view named "(ID)" sorts this the field IDDDOC of DefaultForm.

The DefaultForm is composed of your fields, a Rich Text Field that is
named  "RTFiles" and a Computed Field that is named "IDDOC" with the
@DocumentUniqueID of the document.

In the DefaultForm you must create an action whose JavaScript code
is:
"var wintab;
var id = document.forms[0].IDDOC.value;
wintab =
window.open('/NameBase.nsf/InsertForm?openform&IDDOC='
+id,'','top=150,left=3
50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,
resizable=no,width=420,height=180');
wintab.focus();"

This action opens a new window with the form InsertForm, and in the
Query_String you have the ID of the document that will receive the
file attachments.

In the InsertForm you must create a File Upload, a Field
Query_String, a computed Field with the name "IDDOC" and this code:

@Right(Query_String;"&IDDOC="), a field SaveOptions with the value
"0" and a Computed Field "NamesFiles" with the value
@AttachmentsNames.

In the WebQuerySave event of the InsertForm you will put
@command([ToolsRunMacro];"A-Insert").
And the code for the A-Insert agent is:
           Dim s As NotesSession
           Dim db As notesdatabase

           Set s = New NotesSession
           Set db = s.currentDataBase

           Dim contdoc As notesdocument
           Set contdoc = s.DocumentContext
           Dim iddoc As notesitem
           Set iddoc=contdoc.getfirstitem("iddoc")


           Dim view As notesview
           Dim doc As notesdocument
           Set view=db.getview("(ID)")
           Call view.refresh()
           Set doc = view.getdocumentbykey(contdoc.iddoc(0))

          If contdoc.Hasembedded Then
                     Dim tempfile As Variant
                     Dim RTITEM As Variant
                     Set rtitem=doc.getfirstitem("RTFiles")
                     If (rtitem Is Nothing) Then Set rtitem =
doc.createrichtextitem("RTFiles")
                     Set tempfile =
contdoc.createrichtextitem("tempfile")
                     Dim o As NotesEmbeddedObject
                     Set o =
contdoc.GetAttachment(contdoc.NamesFiles(0))
                     Call o.ExtractFile("c:Temp" + o.name)
                     Call tempfile.EmbedObject( EMBED_ATTACHMENT, "",
"c:temp" + o.name)
                     Kill "c:temp" + o.name
                     Call o.remove
                     If (rtitem.Type = RICHTEXT) Then
                          Call rtitem.AppendRTItem( tempfile )
                          Call doc.save(True,False)
                     End If
           End If
           Dim javascript As String
           javascript
="<script>window.opener.document.location.href=" &
"""javascript:_doClick('Refresh',this,null,null)""" &
";window.close()</script>"
           Print javascript

This agent will insert the file upload in the RTFiles Rich Text Field
and refresh the document.

END CODE

http://searchdomino.techtarget.com/tip/1,289483,sid4_gci760392,00.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
DID THIS TIP WORK FOR YOU? Send us your feedback, and we'll add it to
the tip posted on searchDomino.com. Send you comments and feedback to
[EMAIL PROTECTED] 

OR SEND US YOUR FEEDBACK TO BE POSTED ON THIS TIP TO:
[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
NEW!  KNOW-IT-ALL QUESTION OF THE DAY!  
================================================= 
Quiz yourself to see how much you know about this week's Featured
Topic: Knowledge Management
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
This will allow users to access their Domino-based mail, calendar,
schedule, to-do lists, contact lists, and notebooks from any
computer, at any location, as long as they have an Internet
connection. 

a. .Net
b. J2EE
c. iNotes Web access
d. Domino Off-Line Services 
e. Sametime

Check to see if you are correct! 
http://www.searchDomino.com/originalContent/0,289142,sid4_gci762886,00.html

================================================= 
NEWLY POSTED DEVELOPER TIPS: 
================================================= 
We posted 20 new tips last week. Thanks for all your tips and keep
them coming!

Domino Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283837_alpD_idx0,00.html
[1] Storing user-created HTML form fields in Notes
[2] Offline browser application presentation

HTML Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283838_alpD_idx0,00.html
[1] Search results in XML format
[2] Insert an anchor above the action bar

JavaScript Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283840_alpD_idx0,00.html
[1] Javascript alternative to @ReplaceSubstring
[2] Create link action hotspot

Other Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283842_alpD_idx0,00.html
[1] Using ?OpenView&StartKey on the Web for numbers
[2] Removing unwanted space from in between tables
[3] Formatting computed for display fields on the Web
[4] Optimizing your code
[5] Most useful Notes/Domino URLs
[6] Alternative to Richtext Applet
[7] Getting bullet text on your navigator

Script Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283841_alpD_idx0,00.html
[1] LotusScript agent to send all field values to email recipient
[2] Using roles to build send to fields
[3] Forcing frameset launch on database open
[4] Validation
[5] Application developer
[6] Sort NotesOutline
[7] Concatenating two arrays/strings with Trim and Unique option

================================================= 
Disclaimer: These tips are submitted by your Domino peers. Our tips
services and online tips exchange are a way for you to learn from
other IT professionals and share technical advice and expertise with
your peers. Techtarget.com provides the infrastructure to facilitate
this sharing of information. However, we can't guarantee the accuracy
and validity of the material submitted. You agree that your use of
the searchDomino.com tips services and your reliance on any
questions, answers, information or other materials received through
searchDomino.com will be at your own risk.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
If you would like to sponsor this or any TechTarget newsletter,
please contact Gabrielle DeRussy at [EMAIL PROTECTED]

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



If you no longer wish to receive this newsletter simply reply to 
this message with "REMOVE" in the subject line.  Or, visit 
http://searchDomino.techtarget.com/register 
and adjust your subscriptions accordingly. 

If you choose to unsubscribe using our automated processing, you 
must send the "REMOVE" request from the email account to which 
this newsletter was delivered.  Please allow 24 hours for your 
"REMOVE" request to be processed.

Reply via email to