About Me...

NotesRunningLogoRSmall.png

I'm Kathy Brown and I've been an application developer in Lotus Notes/Domino since 2005.

Prior to working in IT, I've had numerous careers including an Investment Analyst and even an Actress (long ago and far away).

And I (try to) love running!

me.jpg

kathy (at) runningnotes (dot) net

On Twitter, kjbrown13

Upcoming Races

Looking 4 Something?

Disclaimer

This is my personal blog. None of the opinions shown here represent those of my employer. In fact, forget I even have an employer. Any examples given here are strictly fictional and hypothetical and it is pure coincidence if they in any way seem like anything in real life.

« Margaritas Mexican Fiesta 5K | Main| JUST GET OUT THERE AND RUN »

It's Never Easy, Or Is It?

Category DXL Lotusscript
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:

Dim 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)
ls2html was brought to you by nsftools.com

And … no go. It didn’t blow up, but I got an error, ever helpful as always.

DXLfail.JPG

Yes, thanks. Wonderful. Well, fine. Maybe for my first try, I should simplify a bit. Let’s get the DXL from a file.

Dim 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)
ls2html was brought to you by nsftools.com

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

Gravatar Image1 - Great post! I've yet to do much with DXL either so this was really interesting.

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..


Gravatar Image2 - It's funny, when you are doing something new you look and wish there was more info. Then, once you've done it, you forget that you needed more detail. Anyway.

I'm running 8.0.2. In the Designer client, Tools, near the bottom of the list DXL Utilities.

Gravatar Image3 - If you get the "DXL importer operation failed" message, add a DXLImporter.log to the message; this gives you more detailed information and normally even the line in your DXL where the error occured

Gravatar Image4 - I KNEW you'd figure it out. Way to go!
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.

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)