Creating tables with DXL

A customer needed form with 300 questions. To make it dynamic and easy to maintain the questions, these were created with computet for display field. To control the layout we needed tables to structure the fields.
So, each row contained:
– 1 question field
– 1 answer field
– 1 hide/when formula (dont display row if question field is empty)

First some general tables tips:

  • Don’t use large tables – thet preform poorly. Instead, use serveral small tables
  • Don’t merge fields – this will locke your table down (you cant resize, add/delete row etc.). Use nested tables instead

So, we needed to make 30 tables with 10 rows in each and 2 fields per row. You can copy/paste – however you’ll have to manually rename the fields and update the hide/when formulas 🙁
Instead I made one table on a subform and the exported it to DXL(Tool, DXL Utilites, Export from the Designer client)
With Script 1 below I did a search/replace for the fieldnames in the DXL file and made 30 copies of the file. With script 2 I imported the 30 DXL files as new design elements – ready to use.

Some notes

  • When using many subforms – don’t include script libraries in the ‘Globals’ declarations – this will ruin the performance
  • When using many fields: do include this line in the translation formula: @if( @thisvalue=""; @deletefield; @thisvalue). With this you won’t save empty fields !

Script 1

Sub Initialize
        Dim session As New NotesSession
        Dim stream As NotesStream
        Set stream = session.CreateStream
        Call stream.Open( "c:temptable.xml" )
       
        Dim s As String
        s = stream.ReadText
        Print Len(s )
        Call stream.Close
       
        Dim i As Integer
        For i = 1 To 30
                Print i
                While Instr( s, "table" & i ) > 0
                        s = Replace( s, "table" & i, "table" & (i+1))
                Wend
               
                While Instr( s, "." & i & "." ) > 0
                        s = Replace( s, "." & i & "." , "." & (i+1) & "." )
                Wend
               
                While Instr( s, |:= "| & i & "." ) > 0
                        s = Replace( s, |:= "| & i & "." , |:= "| & (i+1) & ".")
                Wend
               
                Call stream.Open( "c:temptable" & (i+1) & ".xml" )
                Call stream.Truncate
                Call stream.WriteText( s )
                Call stream.Close
        Next
       
       
End Sub

Script 2
Sub Initialize
        Dim session As New NotesSession
        Dim db As NotesDatabase
        Dim stream As NotesStream
       
        Set db = session.CurrentDatabase
        Set stream = session.CreateStream()
       
        Dim filename As String
       
        Dim i As Integer
        For i = 5 To 35
                Print i
                filename = "c:temptable" & i & ".xml"
               
                If Not stream.Open( filename ) Then
                        Messagebox "Cannot open " & filename, 64, "Error"
                        Exit Sub
                End If
               
                If stream.Bytes = 0 Then
                        Messagebox "File did not exist or was empty",64 , filename$
                        Exit Sub
                End If
               
  REM Import DXL into new database
                Dim importer As NotesDXLImporter
                Set importer = session.CreateDXLImporter(stream, db )
               
                importer.ACLImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
                importer.DesignImportOption = DXLIMPORTOPTION_CREATE
                Call importer.Process
               
                Call stream.Close
               
        Next
End Sub


Disclaimer: This e-mail and any attachments are legally privileged and confidential and for the use of the addressee only. If you are not the intended recipient, please notify us imme-diately and delete this e-mail. Unauthorised use, disclosure, copying of the contents of this e-mail, or any similar action, is prohibited

2 tanker om "Creating tables with DXL"

  1. Well, in earlier releases Notes had a problem with many subforms and a general problem with loading script libraries. These problems has been fixed.
    I still have problems when using multiple (more than 10) – but only if the subforms loads a script librari in the (Globals) event. When loading from a button or from a form event there is no problem…

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

*