Home > Domino Tips > Developer > LotusScript > Creating a Notes form dynamically
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Creating a Notes form dynamically


Cristian D'Aloisio
09.14.2004
Rating: -3.93- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


I always wanted to create a Notes form dynamically -- with labels and fields, using LotusScript. I realized that using XML with Lotus Notes R6 was the answer: XML for Lotus = DXL.

You can use DXL technology for both exporting and importing Notes design elements. See the R6 Design Help database for an example of exporting design elements (see CreateDXLExporter method). The DXL file exported all database designs, not just a single design element!

The tricky part was importing just a form design definition consisting of labels and text fields (no fancy formatting only bold labels). Studying an exported DXL file, I finally I found the right DXL file for a simple form definition --a file I can use with .CreateDXLImporter method.

Here is a sample DXL file:

<?xml version='1.0' encoding='utf-8'?>
 <!DOCTYPE form SYSTEM 'domino.dtd'>
 <form name='CDAO-64TLV5' xmlns=
'http://www.lotus.com/dxl' version='1.01'>
      <body>
           <richtext>
           
  <pardef id='1'>>
  <par def='1'/>
  <par/>
  <par/>

<par><run><font style='bold'/>
My label 00:
</run></par>
<par><field type='text' kind='editable' 
name='DOM00'/></par><par/> 
<par><run><font style='bold'/> 
My label 01:
</run></par>
<par><field type='text' kind='editable' 
name='DOM01'/></par><par/> 
<par><run><font style='bold'/> 
My label 02:
</run></par>
<par><field type='text' kind='editable' 
name='DOM02'/></par><par/> 
<par><run><font style='bold'/> 
My label 03:
</run></par>
<par><field type='text' kind='editable' 
name='DOM03'/></par><par/>

    </richtext>
   </body>
 </form>

The structure of the sample DXL is rather simple:

Label nn:
[textfield nn]

Below is how to import the above DXL file in R6 using LotusScript.

I suggest you:

  • Pay attention to the DXL import file (no blank line at the top of the file, open/close XML tags, etc.).
  • Study a DXL database output to see how Notes and text fields are translated in XML (bold, field types).
  
Sub importDXL(filedxl As String)
 
 On Error Goto myerror
 
 Dim stream As NotesStream
 
 Set stream = sess.CreateStream
 If Not stream.Open(filedxl) Then
  Msgbox " importDXL() - Error importing file " 
& filedxl 
  Exit Sub
 End If
 If stream.Bytes = 0 Then
  Msgbox "File does not exist!" & filedxl
  Exit Sub
 End If
 
 
 Dim importer As NotesDXLImporter
 Set importer = sess.CreateDXLImporter
(stream, db)
 importer.ReplaceDBProperties = True
 importer.ReplicaRequiredForReplaceOrUpdate
 = False
 importer.ACLImportOption = 
DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
 importer.DesignImportOption = 
DXLIMPORTOPTION_REPLACE_ELSE_CREATE
 Call importer.Process
 
 Exit Sub
 
myerror:
 Msgbox "importDXL() - " & Err & " -
 " & Error & " code line: " & Erl
 Exit Sub
 
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Cristian D'Aloisio. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
LotusScript
Debug Lotus Notes documents using extracted data
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes
Launch large attachments within an email from a Notes database
How to find files on a hard drive or mapped network with LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Create a personalized greeting for Lotus Notes database users

XML and Web Services for Lotus Notes Domino
Verify scheduled agent status with Domino Extensible Language (DXL)
Top 10 Lotus Notes Domino programming and development tips of 2007
A bevy of Notes/Domino development tips
Loading XML from JavaScript
How to apply XSL style sheets to XML views
Top 10 Notes/Domino developer tips of 2006
A smorgasbord of Notes/Domino development tips
Converting XML files into Lotus Notes documents
Finding the properties of a doclinked Lotus Notes document
How to override default Lotus Notes print settings

LotusScript
Debug Lotus Notes documents using extracted data
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes
Launch large attachments within an email from a Notes database
How to find files on a hard drive or mapped network with LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Set a value in a field existing in another Lotus Notes database

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts