Custom web forms – Part 2: Importing Form from DXL
In the second part of Custom web forms series I will try to cover import of simple form to Notes database from DXL file. If you wonder how to export a form to DXL, please check Part 1: Exporting Form into DXL.
Requirements
As mentioned, you will need a DXL file like the result of Part 1. Beware that, if you have altered the file and removed the DOCTYPE tag, you will not be able to import DXL and you will either need to add correct DOCTYPE tag back or export the form again.
The code
The code itself is pretty straightforward. You need to open a DXL file as a NotesStream object and then use NotesDXLImporter class to import a DXL to your database. There is a catch. You need to set DesignImportOption property of NotesDXLImporter object to create design element. These options are specified in Notes Designer Help.
Dim session As New NotesSession Dim dbCurr As NotesDatabase Dim docForm As NotesDocument Dim stream As NotesStream Dim dxlImporter As NotesDXLImporter Dim strFile As String Set dbCurr = session.CurrentDatabase Set stream = session.CreateStream () strFile = "c:\download\templateform.xml" If (Not stream.Open (strFile, "utf-8")) Then Exit Sub End If Set dxlImporter = session.CreateDXLImporter (stream, dbCurr) dxlImporter.DesignImportOption =_ DXLIMPORTOPTION_REPLACE_ELSE_CREATE Call dxlImporter.Process ()
Just in case you don’t want to check Notes help for values, here are DXL import options:
- DXLIMPORTOPTION_CREATE (1)
- DXLIMPORTOPTION_IGNORE (2)
- DXLIMPORTOPTION_REPLACE_ELSE_IGNORE (5)
- DXLIMPORTOPTION_REPLACE_ELSE_CREATE (6)
- DXLIMPORTOPTION_UPDATE_ELSE_IGNORE (9)
- DXLIMPORTOPTION_UPDATE_ELSE_CREATE (10)
Leave a Reply