Hi,
I used the Tools → DXL Utilities-> Export to export the subformRW. Now I want to create the same subform, but with all fields Computed When Composed.
But caring for NotesDXLImporter generates the error NOTES_ERR_DXLIMPORTER_FAILED = 4522.
Can anyone help me find a solution?
Thanks!
Option Public
Option Declare
Use “slUtils”
Dim prvSession As NotesSession
Dim prvInputStream As NotesStream
Dim prvoutputStream As NotesStream
Dim prvOrigXML As String
Dim docNode As NotesDOMDocumentNode
Sub Initialize
Dim domParser As NotesDOMParser
Dim rootElement As NotesDOMElementNode
Dim exporter As NotesDXLExporter
Set prvSession = New NotesSession
prvOrigXML = "c:\xml\subformDXL.xml"
If Not createFiles("") Then
Exit Sub
End if
Set domParser = prvSession.CreateDOMParser(prvInputStream)
domParser.Process
Set docNode = domParser.Document
Set rootElement = domParser.Document.DocumentElement
changeSubform rootElement
changeFields rootElement
domParser.SetOutput prvoutputStream
domParser.Serialize
End Sub
Function createFiles(title As String)
createFiles = True
Set prvOutputStream = prvSession.CreateStream
prvOutputStream.Open "c:\xml\destino2.xml"
prvOutputStream.Truncate
Set prvInputStream = prvSession.CreateStream
prvInputStream.Open (prvOrigXML)
If prvInputStream.Bytes = 0 Then
createFiles = False
End if
End Function
Private Sub changeSubform(rootElement As NotesDOMElementNode)
Dim subFormNode As NotesDOMNodeList
Dim NomeAttr As string
Set subFormNode = rootElement.GetElementsByTagName ("subform")
If subFormNode.NumberOfEntries = 0 Then Exit Sub
Dim x As variant
Set x = subFormNode.GetItem(1)
NomeAttr = x.Getattribute("name")
NomeAttr = ReplaceSubstring(NomeAttr, "RW", "RO")
Call x.Setattribute("name", NomeAttr)
End Sub
Private Sub ChangeFields(rootElement As NotesDOMElementNode)
Dim FieldNode As NotesDOMNodeList
Dim NomeAttr As String
Dim i As Integer
Dim nodeField As NotesDOMElementNode
Dim nodeCode As NotesDOMElementNode
Dim nodeFormula As NotesDOMElementNode
Dim textFormula As NotesDOMTextNode
Set FieldNode = rootElement.GetElementsByTagName ("field")
If FieldNode.NumberOfEntries = 0 Then Exit Sub
For i = 1 To FieldNode.NumberOfEntries
Set nodeField = FieldNode.GetItem(i)
NomeAttr = nodeField.Getattribute("kind")
If(NomeAttr = "editable") Then
nodeField.Setattribute "kind", "computedwhencomposed"
Set nodeCode = docNode.CreateElementNode("code")
nodeCode.Setattribute "event", "defaultvalue"
nodeField.Appendchild nodeCode
Set nodeFormula = docNode.Createelementnode("Formula")
Set textFormula = docNode.Createtextnode("@ThisValue")
nodeFormula.Appendchild textFormula
nodeCode.Appendchild nodeFormula
End If
Next
End Sub