SNTT: Stopping users from opening the wrong replica

One of the great strengths of notes is that users can access the same information on different servers or on local replicas. It can also be a real problem.

I have frequently had calls from people along the lines of

“I added some information and I can see it but my colleague can’t”.

One of our clients recently wanted to deploy replicas of their business critical applications to a different server to improve robustness. Without taking any special steps this actually reduces robustness and user satisfaction because over a period of time users end up using different replicas from each other and sometimes are using a slow server ( a branch office in South Africa on broadband was often a culprit ) without realising this.

The dynamics of how Notes chooses which server to open next often puzzles me but I was once told that it was to do with the alphabetical order of the servers because of the order of the databases in catalog.nsf – and once the top icon is for a distant server users will always use that server.

Anyhow, the code that follows may help. In this particular case the business applications are only used on one site so access to any off-site server should only be required if the on-site server cannot be accessed, his makes it easy – in other projects I have used a rule whereby the application should be accessed on the same server as the persons mail file

There are 3 design elements :

1) an action that creates a profile document listing the name of the preferred server – this is manually triggered when the system is set up

2) some script in the database initialize script which compares the preferred server lists above with the actual server

3) a subform which pops up to alert the user if looks as though they are using the wrong server.

Essentially the code does the following :

checks to see if the person has access to the database
gets the preferred server name from the profile document and compares this with the actual server name.

if the actual server != the preferred server then the system checks to see if the preferred server can be opened.
if the preferred server can be opened then the user is advised as shown in the screen shots below otherwise the user is allowed to open the requested server

I wasn’t able to write code to actually switch to the new database so instead it closes the database and brings the correct icon to the top on the workspace. i have not tried this in a “workspaceless” environment.

Image:SNTT: Stopping users from opening the wrong replica

Image:SNTT: Stopping users from opening the wrong replica

You may think that the steps required to access the “wrong” server are a bit OTT but remember that this pop up only gets triggered when the “preferred” server is available.

Core Code

Sub s_ServerCheck_6_01

‘##############################################################################
‘ Sean cull, www.focul.net, 30/9/08
‘ the purpose of this code is detect the opening of a suboptimal replica and redirect the user to the best replica
‘ this will be tested each time that the database is opened to make sure that the person is opening the most efficient server
‘ other componenets in this functionality are :        
‘sfServerCheck – subform
‘ s_ServerCheck_6_01 ( Database Scripts )
‘AdministrationSet default server ( Agent )

‘##############################################################################

Dim ws As New notesuiworkspace
Dim session As New notessession
Dim db As NotesDatabase
Dim level As Integer
Dim stringStrings As String
Dim profileStrings As notesitem
Dim doc As NotesDocument
Dim currentserver As String
Dim alternatedb As New NotesDatabase( “”, “” )
Dim gooduidb As notesuidatabase
Dim baduidb As notesuidatabase
Dim uidb As NotesUIDatabase
Dim acceptance As Variant
Dim titlestring As String

Set db = session.currentdatabase

If db.server = “” Then
       currentserver = “Local”
Else
       currentserver = db.server
End If

level = db.CurrentAccessLevel

If level < 1 Then ' 1 = depositer
       Print “You do not have access to this database”                
       Exit Sub
End If

Set doc = db.GetProfileDocument(“Default Server”,db.ReplicaID)
If Not doc Is Nothing Then
       Set profileStrings = doc.GetFirstItem(“ProfileStrings”)
       If doc.hasitem(“ProfileStrings”) Then                
               stringStrings doc.profilestrings(0)
               If Not stringstrings = “NONE” Then
                       If Not FoCulCommonName_5_01 (db.server) = FoCulCommonName_5_01 (stringstrings) Then
                               Print “Default server listed as ” & stringstrings & ” but you appear to be on ” & currentserver                                
                       ‘try and open alternate db
                               If alternatedb.OpenByReplicaID( stringstrings, db.ReplicaID) Then
                                       Print( alternatedb.Title & ” was successfully opened” )
                                       Set Doc = New NotesDocument ( db )                                                
                                       doc.recycle_flag_tx = “False”
                                       doc.actualserver_tx = FoCulCommonName_5_01(db.Server)
                                       doc.preferredserver_tx = FoCulCommonName_5_01(stringstrings)
                                       TitleString = “You may be using the wrong server”
                                       
‘                                        flag = notesUIWorkspace.DialogBox
( form$ , [autoHorzFit] , [autoVertFit] , [noCancel] , [noNewFields] , [noFieldUpdate] , [readOnly] , [title$] , [notesDocument] , [sizeToTable] , [noOkCancel] , [okCancelAtBottom] )
                                       Acceptance =  WS.DialogBox( “sfServerCheck” , True , True , True , False , False , False , TitleString , Doc, True , False , True )
                                       
                                       If Not doc.plsContinue_tx(0) = “” Then  ‘ subform negotiated successfully – force this db open
                                               Exit Sub
                                       End If                        
                                       
                                       Print “The preferred database can be opened – switching now”
                                       Set baduidb = ws.CurrentDatabase
                                       
                               ‘Call notesUIWorkspace.OpenDatabase( server$, file$, view$, key$, newInstance, temp )                                        
                                       
                                       ‘ open the preferred database so that the icon is at the top of the icon stack
                                       ‘ then close both ui databases sown
                                       ‘ if anyone has a better method then please let me know !
                                       
                                       Call WS.OpenDatabase( stringstrings, alternatedb.FilePath,””, “”, False, False)                                
                                       Set uidb = ws.CurrentDatabase
                                       Call uidb.Close
                                       Set uidb = ws.CurrentDatabase
                                       Call uidb.Close                                                
                               Else
                                       Print( “Unable to open database – allowing this replica to be used” )
                               End If                                
                       End If
               End If                
       End If
End If
End Sub

You can download a copy of the design elements in a database by clicking the link below. As ever please let me know if there is a better approach !

Blog partially reskinned – I hate IE

I will post more about this but I am part way through reskinning this blog as part of a project to re-develop our company web site.

It works great in Firefox but IE is not so good – reminds me of this graph

Firebug is just brilliant

Click on the comments button to see the old style

Image:Blog partially reskinned - I hate IE

Link

Improving the meta title data on Domino Blog entries ( a passed on tip )

When you look at the Google results for Sean Burgess you will see that the title of the Blog article is clearly shown in Google whereas if you look at my current Google results you can see that the default template behaviour is just to use the site title – I think that Seans method is more informative.

Image:Improving the meta title data on Domino Blog entries ( a passed on tip )

At ILUG 2007 Sean explained that you can change this by using the DXSubject  tag in addition to the DXTitle tag. Note that you can only do this where the page displayed relates to a single article otherwise there is no DXSubject value – took me a while to realise that 😉

In my case I created a new block template called HTMLTopWithSubject and used that on the Document and InlineCommentsDocument page templates.

Image:Improving the meta title data on Domino Blog entries ( a passed on tip )
Image:Improving the meta title data on Domino Blog entries ( a passed on tip )

Steve Castledine, the developer of the IBM Blog Template, has just posted a really useful guide to its configuration :

http://www.stevecastledine.com/sc.nsf/dx/domino-blog-theme-editing-and-tag-library/

Does anyone know why hot spot hyperlinks like the one above don’t always work in the blog template ?

SNTT – Visual Directory – thumbnails in the domino directory

Image:SNTT - Visual Directory - thumbnails in the domino directory

Last year one of our clients asked us to help create a directory of staff with thumbnail images, profiles and contact details. After bouncing it about we agreed that using the Domino directory would make sense as much of the information was already there.

I am always wary of messing with the directory but in this case it was a relatively small directory ( < 200 people ) and we set out to add design elements rather than modify existing design elements. The scheme that we came up with is shown in the images above - essentially the system converts thumbnail images ( 80px x 80px ) into image resources and then displays these image resources in the view. I doubt that this approach will  scale to very large organisations but I have used it on a version of Jake Howletts test directory with 2,000 names and it works fine.

Before launching into the technical description I would like to thank the following people whose code is included in some way :

  • Our client who paid for some of this work and kindly agreed for it to be open sourced – it was a win – win because we obviously didn’t charge them for the open source code that we used.
  • Ewan Arthur, a colleague from FoCul,  who worked with me on the code
  • Julian Robichaux –  http://www.openntf.org/Projects/codebin/codebin.nsf/0/DF779ACFF30EB48886257118004D35B5
  • Lou Capizzoli on Openntf.org  http://www.openntf.org/Projects/codebin/codebin.nsf/0/DF779ACFF30EB48886257118004D35B5
  • Charles Robinson  http://www.cubert.net  ( the my documents folder code )
  • Rocky Oliver / Andre Guiard  http://www.lotusgeek.com/SapphireOak/LotusGeekBlog.nsf/D6Plinks/ROLR-6MBMQJ        


The Scheme

A new form was used to display the persons profile. This form has an action button allowing a jpg file to be uploaded and stored in a rich text field called UserPhoto.

A background agent ( which needs unrestricted privileges ) takes the newly attached jpg files, downloads this to the hard drive on the server and then creates an image resource using DXL using code from Lou and Julian. The name of the image resource is the document unique id of the person record. The jpg file is deleted from the hard drive once the image resource has been created

A new view displays the person records and the image resources associated with each person record. The view has a form formula which forces the new profile form to be used when a document is opened from this view. The form has a form field to make sure that the default form for that record is always the original Domino Directory person form,

In the examples attached below I have left the default domino directory views in place but it is a simple matter to change the default opening view ( edit the Mainframeset ) to be the new one with the images

Note that the forms and code shown here are simplified from the production system but the key concepts still work.

The Design Elements

The only change to the existing elements of the Domino directory is the default view for the mainframeset frameset, everything else uses new design elements. These are :

Forms :

.FoCulPersonProfile

Views :

Focul1. ProfilesBy Name)

Script Library :

.FoCul_Image_Resource_Handling_6_01

Scheduled Agent :

.FoCulUpdate Image Resources ( note that this needs to be set up for your named server )
note that the agent contains a selection rule so that it only runs on records needing to be processed

Other agents :

.FoCulSet images for all people – populates all records with test images stored in c:tempimages  ( may not be MAC friendly )

(.FoCul Remove Profile)

The Downloads

There are four downloads :

Very Small : The script library at the heart of the system

.FoCul_Image_Resource_Handling_6_01.lss

Small : A database with just the required additional design elements ( 0.5 Mb )

designelementsonly.zip

Medium : A full Domino Directory (8.0.2 ) with the original and the new design elements and 10 records ( 3 Mb )

somerecords.zip

Large : The 2000 record Domino Directory with test images ( 40 Mb  )

fakenameswimages.zip

Areas for Improvement

The system probably won’t work on MAC or Linux ( clients and servers ) without some simple changes to the file paths construction

Some code is needed to remove the resource images when a thumbnail or person record is removed

Unashamed Plug

Ewan and I would be very happy to help anyone who wants commercial support to implement this type of system ( or any other system ) via FoCul Ltd. We are based in the UK and have a particularly strong record in developing applications for the Manufacturing sector.