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.