It's Never Easy, Or Is It?
Today I tried my hand at a DXL Import. Guess what? It didn’t flipping work. Surprising, eh?
So, what I was trying to accomplish: I needed to generate a folder for a user, if the user did not already have a particular folder in this application. The folder needed to be able to be updated by the designer whenever requested changes were made (if a change was requested, each folder needed to have the new design), hence I could not use a shared-to-private view. DXL seems all the rage, so why not? Export the folder to DXL, edit and replace folder name to a new folder name, import the DXL and voila! Happy new folder. Added bonus, anytime the folder design changes, I could do the very same thing for all the folders and have the design updated. Extra added bonus, I could learn something new! [Note: a button automagically updates the documents in these folders, so no need to be concerned that I would be zapping meticulously moved documents when I replaced the folders.]
It all seemed too easy. For this exercise, I manually exported a folder using Tools, DXL Utilities, Exporter. Whew. Okay, halfway there, right? Ha. Well, first I tried to get fancy. I wanted to store the exported DXL in a profile doc in the database, and use the NotesDXLImporter (the help says you can use a rich text item) to import the DXL into a domino folder. A little help file here, a little help file there and I had this:
ls2html was brought to you by nsftools.comDim session As New NotesSession Dim db As NotesDatabase Dim importer As NotesDXLImporter Dim doc As notesdocument Set db = session.CurrentDatabase Dim rtitem As notesrichtextitem Set doc = db.GetProfileDocument("adminprofile") Set rtitem = doc.getfirstitem("prodoc_body") Set importer = session.CreateDXLImporter importer.ReplaceDBProperties = False importer.ReplicaRequiredForReplaceOrUpdate = False importer.ACLImportOption = DXLIMPORTOPTION_IGNORE importer.DesignImportOption = DXLIMPORTOPTION_CREATE Call importer.Import(rtitem, db)
And … no go. It didn’t blow up, but I got an error, ever helpful as always.
Yes, thanks. Wonderful. Well, fine. Maybe for my first try, I should simplify a bit. Let’s get the DXL from a file.
ls2html was brought to you by nsftools.comDim session As New NotesSession Dim db As NotesDatabase Dim importer As NotesDXLImporter Dim doc As notesdocument Set db = session.CurrentDatabase Dim stream As NotesStream Set stream = session.CreateStream If Not stream.Open("C:\Documents and Settings\kathy\Desktop\folder.dxl") Then Messagebox "Cannot open " ,, "Error" Exit Sub End If If stream.Bytes = 0 Then Messagebox "File did not exist or was empty" Exit Sub End If Set importer = session.CreateDXLImporter importer.ReplaceDBProperties = False importer.ReplicaRequiredForReplaceOrUpdate = False importer.ACLImportOption = DXLIMPORTOPTION_IGNORE importer.DesignImportOption = DXLIMPORTOPTION_CREATE Call importer.Import(stream, db)
Hey, look at that! I just successfully created a folder from DXL.
Being stubborn, I’ve tried to get the rich text item on the profile doc to work, and it…won’t. Stepping through the debugger, all looks right with the world. The DXL is correctly stored in the profile doc and captured in my code as a rich text item. It just doesn’t work.
So, being really stubborn, I still wanted this to work from a document within the database, rather than a file. Further investigation showed I could get plain text from a profile doc and send that in to a NotesStream. Success! I could now import my folder from a profile document.
Dim session As New NotesSession Dim db As NotesDatabase Dim importer As NotesDXLImporter Dim stream As notesstream Dim doc As notesdocument Set db = session.CurrentDatabase Set doc = db.GetProfileDocument("adminproftext") Set stream = session.CreateStream Call stream.WriteText(doc.GetItemValue("prodoc_body")(0)) Call stream.WriteText(doc.GetItemValue("Body")(0)) stream.Position = 0 Set importer = session.CreateDXLImporter importer.ReplaceDBProperties = False importer.ReplicaRequiredForReplaceOrUpdate = False importer.ACLImportOption = DXLIMPORTOPTION_IGNORE importer.DesignImportOption = DXLIMPORTOPTION_CREATE Call importer.Import(stream, db)
ls2html was brought to you by nsftools.com
So this isn't the most exciting or advanced post in the world. We'll say it's DXL for Dummies. Meaning me.
Oh, and I'm very excited to try ls2html tool from nsftools.com in this post. Pretty cool, huh?
Comments
What version of Notes are you on? Per-8 I assume. Interestingly I don't see "Tools-DXL Utilities" in the 8.02 or 8.5 client. I wonder where it's hiding..
Posted by David Leedy At 16:29:16 On 06/05/2009 | - Website - |
I'm running 8.0.2. In the Designer client, Tools, near the bottom of the list DXL Utilities.
Posted by Kathy Brown At 18:17:56 On 06/05/2009 | - Website - |
Posted by Marcus Foerster At 01:29:10 On 07/05/2009 | - Website - |
We shoulod find out from Lotus if the failure passing a rtitem to the importer is a bug, or something else.
I could see where they'd use a rich text item to get unlimited space, but need a plain-text version of the content for parsing.
Posted by Bob Balaban At 22:50:27 On 07/05/2009 | - Website - |