DXL To The Rescue

Standard

The other day I came across an issue in a lotus notes application that was kind of weird.  The user was getting the ***** error when trying to edit a group in the ACL.

The first thing that came to mind was to check the users access, but they had Manager access to the application.  They just wanted to remove a that was put in the name of a group by mistake, so I tried to make the change myself, but I also got the same error.  I also tried to remove the entry from the ACL, but also got the same error.  The next thing that came to mind was to code an agent to remove the entry by using the back-end lotusscript objects.

So this is what I came up with:

Dim targetDB As NotesDatabase
Dim targetACL As NotesACL
Dim targetEntry As NotesACLEntry

Set targetDB = New NotesDatabase(“”, “”)

If(targetDB.Open(“Server”, “db.nsf”))Then
Set targetACL = targetDB.Acl
Set targetEntry = targetACL.Getentry(“Group With / in its name”)
If(Not(targetEntry Is Nothing))Then
‘targetEntry.Name = “TestEntry”
Call targetEntry.Remove()
Call targetACL.Save()
Else
Print “Entry not found in ACL”
End If
Else
Print “Not able to open db”
End If

But when I tried running the agent I got the same error when trying to execute the line Call targetACL.Save().  I then did some searching on the web and found a few people with the same error, but most of them suggested the ACL was corrupt and that the way they solved the issue was to create a new application and copy the data over, but this would only be an option for me as a last resort.  Since it seemed like the cause was the ACL had become corrupt I thought I’d export the ACL to DXL and verify if there was anything strange in the XML.

I created the following agent to export the ACL:

Dim s As New NotesSession
Dim targetDB As NotesDatabase
Dim fileName As String

Set targetDB = New NotesDatabase(“”, “”)

If(targetDB.Open(“Server”, “db.nsf”))Then
REM Open xml file named after target database
Dim stream As NotesStream
Set stream = s.CreateStream()
fileName = “c:temp” & Left(targetDB.FileName, Len(targetDB.FileName) – 3) & “xml”
If Not stream.Open(fileName) Then
Print “Cannot open ” & fileName
Exit Sub
End If
Call stream.Truncate

Dim exporter As NotesDXLExporter
Set exporter = s.CreateDXLExporter

REM Create note collection of actions
Dim nc As NotesNoteCollection
Set nc = targetDB.CreateNoteCollection(False)
nc.Selectacl = true
Call nc.BuildCollection

Set exporter = s.CreateDXLExporter(nc)

Call exporter.SetInput(nc)
Call exporter.SetOutput(stream)

‘ Stops the from being added to output.
exporter.OutputDOCTYPE = False

Call exporter.Process
Else
Print “Could not open db”
End If

After running this agent the following content was generated in the Test.xml:

 

replicaid=’852574830021CC9F’ path=’CN=Test/OU=Test/OU=Server/O=Test!!db.nsf’
title=’Test DB’ usejavascriptinpages=’false’>

percentused=’97.7727051598594′ numberofdocuments=’39’>
dst=’true’>20101006T162213,08-04
>20101007T094423,47-04

writepublicdocs=’false’/>

deletedocs=’true’/>

level=’editor’ deletedocs=’true’ createpersonalagents=’false’ createpersonalviews=’false’
createsharedviews=’false’ createlsjavaagents=’false’/>
10/06/2010 04:20:38 PM Test User/Test/Test updated Test Admins
10/06/2010 04:20:31 PM Test User/Test/Test added Test Admins

Since I did not see anything strange in the ACL DXL I decided to create an agent that would import the ACL DXL after removing the group with the / in it’s name from the DXL.  This is what the agent looked like:

    Dim s As New NotesSession
Dim targetDB As NotesDatabase
Dim fileName As String

Set targetDB = New NotesDatabase(“”, “”)

If(targetDB.Open(“Server”, “db.nsf”))Then
REM Open xml file named after target database
Dim stream As NotesStream
Set stream = s.CreateStream()
fileName = “c:temp” & Left(targetDB.FileName, Len(targetDB.FileName) – 3) & “xml”
If Not stream.Open(fileName) Then
Print “Cannot open ” & fileName
Exit Sub
End If

If stream.Bytes = 0 Then
Print “File did not exist or was empty”
Exit Sub
End If

‘Import DXL into new database
Dim importer As NotesDXLImporter
Set importer = s.CreateDXLImporter(stream, targetDB)
importer.ReplicaRequiredForReplaceOrUpdate = False
importer.ACLImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE

Call importer.Process
Else
Print “Could not open db”
End If

After running this agent I verified the ACL of the application and the group was no longer there.  I also tested that new entries could be added and modified without issues.

Has anybody run into similar issues before, where you had to resort to DXL for a fix?

Notes Net Forums xPages Design Update

Standard

I was looking through the notes.net forums last night and it occurred to me that they badly need a design update. So I went to ideajam and searched to make sure that nobody had already created an idea about this, it turns out someone had, so I promoted the idea and I urge everyone that uses the forums to do the same. I’m a bit surprised as to why IBM hasn’t already updated the design of the forums to the new xPages design, I mean it seems like the logical thing to do since it shows off the cool stuff you can do with the new version of domino. I mean what better way is there to show off xPages? The forums are used daily by hundreds of users yellowbleeders, newbies, and most importantly people that don’t like notes/domino but are forced to work with it where they work. Who knows maybe these last people will start to like notes/domino a bit more once they see the new cool stuff that can be done with xPages.

Head over to ideajam and promote the idea if you haven’t already–> Improve notes.net forums

Code That Makes You Say… Huh? #1

Standard

Photo By Andyrob

Most of the work I do at my current job is maintenance to existing applications within my team.  A while ago I found an interesting line of code within a lotusscript library.

TStamp = Evaluate(“@Text(@Now)”)

It seems the developer that did this doesn’t know that there is a Now function in lotusscript.

I have found this same line in most of the applications that I maintain and I’ve also seen it in applications that I don’t maintain.  Worst of all, most of these applications are used globally and this line is used to capture the date and write it to an audit trail.  What’s wrong with this you ask?  Well you don’t have a consistent audit trail, for example the date format in the UK is not the same as in the US.

Two solutions to fix this would be:

  1. Make the audit trail date field a multi value date field and use the Now function to append the date value to the field.  With this approach you can use the field properties to adjust the format for displaying the dates.  This allows you to display the dates in the users local format or choose a specific format.
  2. Use the Format function in combination with the Now function to get the same date format everytime.  With this approach you ensure a consistent date format within the audit trail, but you loose the ability to display the dates in the users local format.

Have you found code that makes you say Huh in applications you maintain?

P.S. I’ve tried telling the developer that maintains the other applications to modify the code, but that’s another story…

Better Lotus Notes DB Icons

Standard

If you haven’t done so, please head over to the Notes Design blog and ideajam and give your input.  We have been asking for application icons to allow more colors for as long as I can remember.  The application icon is the first thing the user sees and let’s face it, 16 color icons does make the application look like legacy software.  So anyways just head over to ideajam and promote the ideas the more votes it has the more likely it will be done.

Allow Notes Database icon to have 24-bit (=16.7 million) colors
Allow .png and .svg image resources

Better Java Development with Domiclipse

Standard
I have been using Domiclipse for over 2 years now and it is a great tool when doing java development within Notes.  It’s basically a set of plugins that allow you to import a notes application as a java project into eclipse and do development using all the great tools included in eclipse.  Then it lets you sync your changes back into your notes application with a click of a button.  Anyway, I decided to post a step-by-step tutorial of how to install Domiclipse into your existing copy of eclipse.First we open up the eclipse environment and we click on the Help–>Software Updates… menu item.

Next we have to add the update site url for Domiclipse.  On the Software Update and Add-ons window click on the Available Software tab and then click on the Add Site… button on the right.

Next we add http://www.domiclipse.com/domiclipse/update.nsf as the location in the Add Site window and click on OK.

Once we have added the site to the Available Software, expand the site by clicking on the + on the left of the new site and this will fetch the available plugins from the Domiclipse site.  Next we want to expand the eclipse category and check the box next to the Domiclipse Java Feature.  The next thing to do is click the Install… button on the right and this will start the installation.

The next screen will ask you to confirm your choice, just click on the Next >

Next you will be asked to accept the license, here you will have to click on the I accept the terms of the license agreement radio button and then click on the Finish button.

After the installation finishes you will need to shutdown eclipse and open the properties for your eclipse shortcut.  Here you will have to edit the Start in: property to match your Notes program directory in my case it is C:Notes

The final step would be to start up eclipse and verify that you have the Domiclipse icons on your toolbar.

Congratulations you have just installed Domiclipse into your eclipse environment.  Hope this helps some of you new that are new to java and eclipse.  Domino designer 8.5.1 is supposed to have most of the eclipse features, but Domiclipse will still be a great asset to those that don’t upgrade right away, which I’m guessing is most of us.

Embbeded Docs in Form

Standard
I ran into a strange situation the other day in a lotus notes application I have to maintain at work. When I edited the main form the first time and saved it, it took over 5 minutes to save!! When I looked at the size of the template is was over 90MB, it didn’t have any data in it, and the % utilized was 99%. So first thing I tried was to delete all design elements except for the form and compacted the template, that didn’t help. Next I decided to export the form using DXL, since opening it in the designer didn’t show anything out of the ordenary.

What I found was very interesting, at the end of the form element there seemed to be over 5 MS word documents “attached”. I also found some weird fields that seem to be stuff attached to the form also. Using the technique described in Make a Notes view list design elements I created an agent to create a view to show the form element, then I created an action to delete the weird fields from the form.  As soon as I ran that action and compacted the template it went down to 30MB.

I for one have never seen this situation before, have any of you ran into something similar?  What was the cause?

Notes Views with Colors

Standard
After reading Jake Howlett’s blog entry How-To: Shade Your Views Based on Document’s Age, I wanted to try the technique out on an application that runs on the lotus notes client and I would use the built in feature in Notes for assigning colors to rows.To use this feature you check the “Use value as color” property of the column
color-col-props

Then, assign the column a formula that will evaluate to either a list of three numbers between 0 to 255 or a list of six numbers also between 0 to 255.  If you send only three values that will become the RGB color for the text and if you send six values the first three will become the RGB for the background and the other three will be for the text.  It is also good to mention that these colors will take effect on all columns right of the color column, so it is not a good idea to create this column at the end of the view.

Example of values for column:
255:0:0  –  Red Text
143:255:87:0:0:0  –  Green background with black text
255:0:0:0:0:0  –  Red background with black text

Here is a screenshot of the resulting view.  By adding these visual indicators I could even remove the creation date column and users would be able to tell the age of the documents.
colored-view

The documents in the application I’m planning to use this technique on are measured in minutes and not on days, so I would schedule the agent to update the view column formula every 5 minutes instead of nightly.

So now I ask, what kind of performance impact would this have on the database if any?

Lotusscript Dir Function Causes Domino Crash

Standard
After many debugging and troubleshooting efforts IBM has provided a hotfix for the issue I discussed in Attachment ExtractFile Limitation post.  It seems that the lotusscript Dir function causes a server crash in version 7.0.2 and it seems that it may also be the case for version 8 and probably pre 7 versions.  When a path longer than 255 characters is passed to the Dir function it causes a crash instead of throwing an error.  This can easily be fixed by checking the path length before sending it to the Dir function, but it was a bit troublesome to track down because you don’t expect the server to crash when calling a simple function so most of the time attention is focused on other more complex functions and third-party functions.

Hope this helps anybody that runs into the same situation.