There's a function in the menu of Domino Designer to export selected design elements into a DXL file (Tools / DXL Utilities / Exporter). However, there's no corresponding function to import design elements from a DXL file into the current database. Since I needed to do that today, I thought I would share the code in case it's of any use the the folks out there in Dominoland.
This script is set to import only design elements, to not require that they came from the same database, and to replace existing design elements with the same name. If that's not what you want, you could of course go in and change those lines. You would use it in an agent set to run on no documents.
Once the import is done, the script also signs the new design elements. This isn't needed for every type of design element, but it is for most and it doesn't harm the others.
Andre Guirard | 20 March 2007 09:52:24 AM ET | Man-Cave, Plymouth, MN, USA | Comments (21)
Andre, is there an option available for replacing an existing element based on UNID instead of name?
Offhand, I don't know how to do that. Of course, if the aliases match, the replace will happen, so that lets you change the "user facing" title while still having a matching identifier. What's your application?
Is it really important that the UNIDs remain the same, or did you just want to replace the right design elements? Because you could parse the DXL input yourself prior to importing, read off the UNIDs, and store them (in a List datatype, probably best). Then import, and loop thru the list of imported elements (just as my example code does). As you do that, delete the UNID of every imported document from the list. The remaining list entries represent design notes that were not replaced during the import, presumably because the names didn't match. Use the UNIDs to find those notes and delete them.
Thanks, Andre. The scenario I have in mind is one in which design information is being exported to DXL, modified externally or programmatically, then reimported. If the element is renamed in the process, it creates a duplicate instead of updating the existing element. My current approach is to detect name changes prior to the import, then get a handle on the design element via its UNID, overwrite the $TITLE field with the new name, then perform the import. It works, but I was hoping there was a simpler way.
Hi,
I have a problem with a form that is corrupt after Notes crashed. If I tried to open the form I get the message 'Is not a form'.
I first did an DXL export which resulted in a fine DXL file with all the info.
When I then do an import via the code you provide I only get an empty form in return.
:-?
Great timing Andre, I just yesterday looked at that menu and had to mutter a few choice words when the import option was missing. I also happen to have been looking closely at DXL lately in the context of developing various approaches to "skinning" a Notes client app. I've got a pretty slick working model for applying Action bar attributes to select design elements, using an embedded view to preview the actionbar style before applying to selected elements. It's based on the "ActionBar" OpenNTF project.
I'm hopeful that I'll be able to do something similar with frameset borders and embedded outline backgrounds to apply a new color scheme in one shot. However, even if I don't use DXL to modify those elements in place, I could pretty easily use your code to pull in variations of those elements from a separate "skin" database.
I don't know... it sounds like maybe there was a problem with the form before you exported it. When you look at the DXL, do you see the stuff that's supposed to be in your form? The fields and so on?
I have the same problem and not in one opportunity... I had this problem many times.... and I never could recover the form.... always needed to start again.
What can i do? or How can i prevent this problem, cos I lost many develops......
Is this for a particular version of Notes?
I'm using this code to import your "re-ordering items" form and I'm getting an error during the actual processing.
I'm on Notes 6.5.5 so I'm wondering if the issue is the version difference.
Just get the message "DXL importer failed".
Wayne
> Is this for a particular version of Notes?
> I'm using this code to import your "re-ordering items" form and I'm getting an error during the actual processing.
> I'm on Notes 6.5.5 so I'm wondering if the issue is the version difference.
> Just get the message "DXL importer failed".
Oh. The form was designed and exported with version 8.0 beta. I guess the DXL has some new stuff in it that Notes 6.5.5 doesn't recognize, even though there's no reason the form itself shouldn't work. I'll package it up as an NSF and update the blog entry in a bit.
Hello Andre
I have first created one scheduled agent called "Test" and now I want to change the scheduled time frame using a modified version of your script.
The error I get is note item not found, I have tried using different designimportoptions, tried setting the unid and noteid but that does not help.
However if I export the whole agent DXL code , change it, and then import the whole agent DXL code again using your importcode, it works ?
Any ideas what my code is missing in order to change the agent schedule ?
Thanks
Thomas Adrian
{ Link }
On Error Goto oops ' standard error trapping
Dim session As New NotesSession
Dim dxli As NotesDXLImporter
Dim db As NotesDatabase
Dim stream As NotesStream
Dim inputfile
Dim wksp As New NotesUIWorkspace
Set stream = session.CreateStream
stream.WriteText(|<?xml version='1.0' encoding='utf-8'?><agent name="Test">|)
stream.WriteText(|<trigger type="scheduled"><schedule type="byminutes" hours="12" minutes="2" runlocation="local" /></trigger></agent>|)
Set db = session.CurrentDatabase
Set dxli = session.CreateDXLImporter(stream, db)
dxli.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE
dxli.ACLImportOption = DXLIMPORTOPTION_IGNORE
dxli.DocumentImportOption = DXLIMPORTOPTION_IGNORE
dxli.ReplicaRequiredForReplaceOrUpdate = False
dxli.ReplaceDBProperties = False
dxli.Process
' if the import succeeded, sign the new design notes.
If dxli.ImportedNoteCount Then
Dim strID$
strID = dxli.GetFirstImportedNoteId()
Do Until strID = ""
Dim docDesign As NotesDocument
Set docDesign = db.GetDocumentByID(strID)
Call docDesign.Sign()
Call docDesign.Save(True, False, True)
strID = dxli.GetNextImportedNoteId(strID)
Loop
End If
Exit Sub
oops:
Msgbox "Error " & Err & " line " & Erl & ": " & Error
Exit Sub
Missed to tell you one thing, The script I did above runs without problem, no errors what so ever, but when I try to access the agent "Test" I get Note item not found.
Thomas
www.notessidan.se
Well, I did some more tests.
It seems as I get the "note info not found" if the xml code sent to the importer does not contain any code.
i.e if I add the following xml to the script above it works fine, the problem is that I do not want to modify the code ?
Is this a bug ?
<code event='initialize'><lotusscript>Sub Initialize
Print ""
End Sub</lotusscript></code>
Thomas Adrian { Link }
Thomas,
It seems you're expecting that only the parts of the agent DXL that you include tags for will be replaced. In fact, every item is removed from the design note and replaced with data from the DXL. So you need to fully specify the agent in your DXL, including all the source code. To make one little change in an existing agent, start by exporting the agent to a parser -- the DOM parser is good for this -- to find the tag whose attributes you need to modify and replace the relevant values, then import the resulting XML.
Thank you, I did not think of that. the designimport options does not support update , only documentimportoptions do.
/Thomas
I m not able to access my form in designer . Pops up "Not form"
can u help me ?
Dear vinay,
i m facing the same problem in one fo my forms. I hope u have kept a back-up. It seems to be that some access formula seems to be causing the problem.
Will tell u if i find out.
Andre, I tried to use this import agent to pull in the defaultform dxl you posted here: { Link } but it failed. Using 8.0.1. You mentioned updating this entry with an nsf, and I was thinking maybe you could put the defaultform in there as well.
Thanks.
I have added your import-agent to my apps, which are used by hundreds of companies. Now I have a minor error in an agent, that I was hoping to be able to fix by sending them a DXL-file with the new code. But unfortunately, it seems that they can only import in their client, if the export was done with exact the same version of Notes.
Any suggestions to make it backwards compatible mostly welcome (mail: keh@hojslet.dk)
I have imported DXL file it gives Lotus notes error notification while I run an exe..
Question: Can I modify the DXL so that any 6.5+ client will be able to import it ?
Sure you can. Within the DXL file there will be a reference to domino_8_0_2.dtd or domino_8_0_2.xsd. Change that to domino_6_5.dtd or domino_6_5.xsd and the import should work. Currently the import is failing for your customer is because the importer is looking for domino_8_0_2.dtd/xsd with the xmlschemas directory with the data directory on your customers machine.
Regards
- Sumeet
_____________________________
Sumeet Toprani, Project Manager
Lotus Software, IBM Software Group

