TexasSwede
texasswede@gmail.com
  • About this blog
  • My Website
  • My Resume
  • XML Export Tool
  • Photos

Category Archives: IBM/Lotus

IBM Notes and Domino 9.0 Social Edition

Posted on November 13, 2012 by Karl-Henry Martinsson Posted in Featured, IBM/Lotus, Notes/Domino 4 Comments

This morning, IBM presented the latest version of Notes and Domino. The new product name is IBM Notes 9.0 Social Edition. As you notice, the Lotus name is now gone, and the look is changed to look more like other IBM applications, with a more modern design. There are also changes and updates to the user interface inside the different parts of the client.

IBM Notes 9.0 Social Edition - Welcome Screen

IBM Notes 9.0 Social Edition – Welcome Screen

 

One thing, totally new for Notes, is that tutorials and training videos are available in the client.  The tutorials are not just for new functions, but also older tips and tricks that will make the users more productive.

During the presentation, new functions in mail and calendar were demonstrated. One function that will surely be popular with users is to group mail by date:

Other new features shown were the ability to color code different categories of meetings using custom colors and improved monthly view, as well as a weekly planner taken from Organizer.

The activity stream is using the OpenSocial standard, and Domino is now supporting OAuth and SAML for authentication. Customers can however deploy Notes 9.0 without the Social Edition functions, and add them later.

Not only has the traditional Notes client been updated, iNotes is also updated to look even more like the rich client. One of the biggest news in this version is the Notes browser plugin, that allow user to run traditional Notes applications directly in the browser, in full fidelity with no Notes client installed. The new version of iNotes also contains the new activity stream, as shown in the image below.

 

The new version of Traveler will (in addition to iPhone and Android) also support the Blackberry 10 platform and Windows Phone 7.5/8, and now also be available for IBM iSeries.

A public beta version of Notes 9.0 Social Edition will be available December 14. For previous versions of Notes, since (if I remeber correctly Notes 5), IBM have been doing managed beta testing and not released public beta version.
The final version is planned for Q1 2013. IBM also outlined the future roadmap for the next couple of years, which included a new major realease in 2015:

Using jQuery to emulate Notes hide-when

Posted on November 6, 2012 by Karl-Henry Martinsson Posted in Frameworks, Javascript, Notes/Domino, Web Development 1 Comment

We have all built applications in Lotus Notes where we use the value of a checkbox, radio button or dropdown box to show or hide additional fields, like you can see in this clip.

But the hide-when formula will not work this way on the web. The Domino HTTP stack will simply render the page before sending it to the browser, and even if you make a selection in the browser, the hidden section will not display or vice versa.
So what can you do? One easy way is to use jQuery (or Dojo, if you rather fancy that). You can then detect if a checkbox/radio button is clicked on or if a dropdown box is changed. Then you read the value of the button/box and hide/show the content you like.

 

In this example, you can also see that that one of the dropdown boxes actually switch which dropdown box to display next to it, you can see that the available choices are different, in addition to performing the more visible hiding of the last row when recommendations is not set to “n/a”.
So how do you actually do this? It is fairly easy.
First you add a reference to the jQuery library to the HTML Head Content section of the form. Remember that you need to prefix any quote marks with a \ when you put it in as a string. Here I am calling the Google-hosted jQuery library:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
Next, remove any hide-when formulas from the form you are going to expose on the web. That is important, since the Domino server will otherwise not render all the HTML you need. Then give each element you want to hide a unique id. You are probably using tables to create the layout you want, then you can use the table cell id to address the element.

 

In this case, I give the cell containing the label the id “ReasonNALabel” and the cell containing the dropdown box the id “ReasonNA”. The field ‘Recommendation’, which is the one where we are detecting the click and if it has the value “n/a” should display the two cells below it, has an id of “Recommendations”.
One more thing, we want to detect the value as soon as the page is loaded, and display/hide the section accordingly. I will break out the code that perform the check of the value and does the hide/show, so I can call one function insted of duplicating the code.
 

$(document).ready( function () {
    // Check value and do initial show/hide after page is finished loading
    refreshRecommendations();
    // Set trigger for click on radio button to call function
    $("input[name='Recommendations']").click( function() {
        refreshRecommendations();
    });
});

function refreshRecommendations() {
    var checked = $('input[name=Recommendations]:checked').val();
    if (checked == "n/a") {
        $("#ReasonNA").show();
        $("#ReasonNALabel").show();
    } else {
        $("#ReasonNA").hide();
        $("#ReasonNALabel").hide();
    }
}

 

If you want to check the value if a checkbox, use  $(“#checkboxID”).is(“:checked”) and to check the value of a dropdown box, use $(“#dropdownboxID”).val(). For the dropdown box, use .change() instead of .click(), otherwise the code is identical.

 

That is it, a few lines of jQuery to duplicate your hide-when functionality on the web.
Bonus tip: If you want the ítems to fade in and out gradually, you can use jQuery for that as well. You just replace .show() with .fadeIn(‘slow’) and .hide() with .fadeOut(‘slow’). Now you get a nice slow (about 1 second) fade effect instead of instant change.
You can also set the duration of the fade in milliseconds instead, for example .fadeIn(500) for a half-second fade. Another neat thing is that you can define a call-back function to execute after the fade is done. Below is an example of that, where one div is faded out in 750 milliseconds. When that is done, another one is faded in (for half a second) and finally a message is displayed when everything is done.
$("#Section1").fadeOut(750, function() {
    $("#Section2").fadeIn(500, function() {
        alert("Done.");
    });
});

Replace images on web page using jQuery

Posted on October 31, 2012 by Karl-Henry Martinsson Posted in Frameworks, Javascript, Notes/Domino, Programming, Web Development 3 Comments

Last week I encountered a situation where I wanted to replace images on a Domino generated webpage. I am sure you all know what doc links look like by default when rendered by the Domino HTTP task:

Domino Default Icons (click for larger version)

 

By adding a few lines of jQuery to the form, you can manipulate the image source, as well as the CSS class and other attributes. This allows you to modify a page served by the Domino HTTP task almost as much as you like.

Below is the code I used to modify what you see above into something that I found a little bit nicer.

        $("img").each( function() {
        var t = $(this);
        imgicon = t.attr("src");
        if (imgicon == "/icons/doclink.gif") {
           t.attr('src', '/applications/losscontrol.nsf/icon_picture.gif');
           t.addClass('photoicon');
        } 
        if (imgicon.indexOf("Attachments") > 1 ) {
           t.attr('src', '/applications/losscontrol.nsf/icon_attach.gif');
           t.addClass('attachmenticon');
           t.attr('height','16');
           t.attr('width','16');
        } 
    });
    $("a").each( function() {
        var t = $(this);
        url = t.attr("href");
        if (url.indexOf("$FILE")>0) {
           t.removeAttr("style");
           t.addClass('attachmentLink');
           t.outerHTML = t.outerHTML + "<br>";
        }
    });
    var plink = $('#photolinks').html();
    plink = plink.replace(/<br>/i,'');
    plink = plink.replace(/<\/a><font\b[^>]*>/gim,'<span class="photoLink">');
    plink = plink.replace(/<\/font>/gim,'</span></a>');
    $("#photolinks").html(plink);

    var alink = $('#attachmentlinks').html();
    alink = alink.replace(/<\/a>/ig,'</a><br>');
    $("#attachmentlinks").html(alink);

 

What I am doing is to loop through all img tags on the page, and identify the ones that are doc links (using the file name for the icon). I replace the src attribute of those links with a different icon I added as an image resource to the database. I then set the class name for the link, so I can manipulate the look using CSS.

I also look for any src attribute containing the field name “Attachments”, which is where the attachments (if present) are located. I change the icon from the one generated by Domino to another image resource in the database.

The next section of the code will loop through all anchor tags and check if the link includes “$FILE”, indicating it is an attachment. If that is the case, I remove the Domino generated style attribute, set a class name and append a line break to the end of each link.

I then perform some string replacements to remove the font tags that Domino generate automatically when rendering rich text fields. I replace the font tags with a span (containing a class name) so I can style the look of the link later, and also move the </a> tag to after the link text. The last thing I do is to add a line break after each attachment link.

Here is the result:

Domino jQuery Icons (click for larger version)

 

Hope this can help anyone. And if you wonder, I am using the fieldset tag to create the box around each set of icons.

Domino jQuery

Free Tool: Analyze ACL in Notes Application/Database

Posted on November 16, 2011 by Karl-Henry Martinsson Posted in Lotusscript, Notes/Domino 3 Comments

Yesterday my network admin asked me if I could write a simple tool that could provide him with with a spreadsheet of what users had access to a certain database, and through what groups and roles. A couple of hours later I had created an agent that analyze the ACL and identify the users who can access it. The result is presented as a CSV file.

I am sharing the code below. It is pretty straight forward. As you can see, I am using lists to hold the data for easy export later to CSV. Run the code with the Lotusscript debugger turned on, and put a breakpoint before the CSV export starts, and you can see how the data is stored in the lists.

The function ExpandGroups() is called recursively to drill down, if the group contains additional groups. This function also use a lookup into a custom view, (LookupPeople), that we have in our corporate NAB, I am sure you can modify this code with something that works for you.

Enjoy! As always, use the code on your own risk, no warranties, etc.

%REM
    Agent Export ACL Info to CSV
    Created Nov 14, 2011 by Karl-Henry Martinsson/Deep-South
    Description: Read ACl for specified database and create a
    CSV file with info about each user's access (roles, groups,
    delete access, access level).
%END REM

Option Public
Option Declare

Dim nab As NotesDatabase

Type RowData
    role As String
    group As String
    username As String
    deletedoc As String
    level As String
    levelno As Integer
End Type


Class GroupData   
    Public roles List As String
   
    Public Sub New()
       
    End Sub
End Class


Class PersonData
    Public accesslevel As Integer
    Public roles List As String
    Public deletedoc As boolean
    Public accessthrough List As String
   
    Public Sub New()
        me.deletedoc = False
    End Sub
   
    Public Sub SetAccessLevel(level As Integer)
        If me.Accesslevel<level Then
            me.AccessLevel = level
        End If
    End Sub

    Public Function GetAccessLevelText()
        Select Case me.AccessLevel
            Case 0 : GetAccessLevelText = "No Access"
            Case 1 : GetAccessLevelText = "Depositor"               
            Case 2 : GetAccessLevelText = "Reader"
            Case 3 : GetAccessLevelText = "Author"
            Case 4 : GetAccessLevelText = "Editor"
            Case 5 : GetAccessLevelText = "Designer"
            Case 6 : GetAccessLevelText = "Manager"
        End Select
    End Function
End Class


Class RoleData
    Public groups List As String
   
    Public Sub New()
       
    End Sub
End Class


Sub Initialize
    Dim ws As New NotesUIWorkspace
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim pview As NotesView
    Dim pdoc As NotesDocument
    Dim acl As NotesACL
    Dim entry As NotesACLEntry
    Dim person List As PersonData
    Dim group List As GroupData
    Dim role List As RoleData
    Dim users As Variant
    Dim row List As RowData
    Dim cnt As Long
    Dim groupname As String
    Dim filename As String
    Dim rowstr As String
    Dim dbname As String
    Dim servername As String

    servername = InputBox$("Enter server for database:","Select Server")
    If servername = "" Then
        Exit Sub
    End If
    dbname = InputBox$("Enter full path of database:","Select Database")
    If dbname = "" Then
        Exit Sub
    End If
    set nab = New NotesDatabase(servername,"names.nsf")
    Set db = New NotesDatabase(servername,dbname)
    Set acl = db.ACL
    Set entry = acl.GetFirstEntry()
    Do While Not entry Is Nothing
        If entry.Isgroup Then
            If IsElement(group(entry.Name))=False Then
                Set group(entry.Name) = New GroupData()
                ForAll r In entry.Roles
                    group(entry.Name).roles(r) = r
                End ForAll
            End If
            users =    ExpandGroup(entry.Name)
            If IsList(users) then
                ForAll u In users
                    If IsElement(person(u))=False Then
                        Set person(u) = New PersonData()
                    End If
                    Call person(u).SetAccessLevel(entry.level)
                    If entry.Candeletedocuments Then
                        person(u).deletedoc = True
                    End If
                    person(u).accessthrough(entry.Name) = entry.Name
                    ForAll r In entry.Roles
                        If FullTrim(r)<>"" then
                            person(u).roles(r) = r   
                        End if
                    End ForAll
                End ForAll
            End If
        ElseIf entry.IsPerson Then
            If IsElement(person(entry.Name))=False Then
                Set person(entry.Name) = New PersonData()
            End If
            Call person(entry.Name).SetAccessLevel(entry.level)
            If entry.Candeletedocuments Then
                person(entry.Name).deletedoc = True
            End If
            person(entry.Name).accessthrough("ACL") = "ACL"
            ForAll r In entry.Roles
                If FullTrim(r)<>"" Then
                    person(entry.Name).roles(r) = r
                End if   
            End ForAll
        End If
        Set entry = acl.GetNextEntry(entry)   
    Loop   
    ForAll g In group
        ForAll rr In g.roles
            If IsElement(role(rr)) = False Then
                Set role(rr) = New RoleData
            End If
            role(rr).groups(CStr(ListTag(g))) = ListTag(g)
        End Forall
    End ForAll
    ' *** Time to export the data
    cnt = 0
    Set pview = nab.GetView("(LookupPeople)")
    ForAll p In person
        ForAll gg In p.accessthrough
            groupname = gg
            If IsElement(group(groupname)) And groupname<>"ACL" Then
                ForAll r2 In group(groupname).roles
                    cnt = cnt + 1
                    row(cnt).username = ListTag(p)
                    row(cnt).group = groupname
                    If p.deletedoc then
                        row(cnt).deletedoc = "Y"
                    Else
                        row(cnt).deletedoc = "N"
                    End If   
                    row(cnt).levelno = p.accesslevel
                    row(cnt).level = p.GetAccessLevelText()
                    row(cnt).role = ListTag(r2)
                End ForAll
            End If
        End ForAll
    End ForAll
    filename = "c:\ACL_"
    filename = filename & Replace(Replace(dbname,"/","-"),"\","-")
    filename = filename & ".csv"
    Open filename For Output As #1
    rowstr = |"UserRole","Group","User Name","Del","Level","Access"|
    Print #1, rowstr
    ForAll x In row
        rowstr = |"| & x.role & |",|
        rowstr = rowstr & |"| & x.group & |",|
        rowstr = rowstr & |"| & x.username & |",|
        rowstr = rowstr & |"| & x.deletedoc & |",|
        rowstr = rowstr & || & x.levelno & |,|
        rowstr = rowstr & |"| & x.level & |"|
        Print #1, rowstr
    End ForAll
    Close #1
    MsgBox "ACL exported to " & filename,,"Finished"
End Sub


%REM
    Function ExpandGroup
    Created Nov 14, 2011 by Karl-Henry Martinsson/Deep-South
    Description: Returns a list of users in specified group in NAB
%END REM
Function ExpandGroup(entryName As string) As Variant
    Dim nabview As NotesView
    Dim nabdoc As NotesDocument
    Dim pview As NotesView
    Dim pdoc As NotesDocument
    Dim uname As NotesName
    Dim tmplist As variant
    Dim userlist List As String
   
    If FullTrim(entryName) = "" Then
        ExpandGroup = ""
        Exit Function
    End If
    Set nabview = nab.GetView("Groups")
    Set nabdoc = nabview.GetDocumentByKey(entryname)
    If nabdoc Is Nothing Then
        ExpandGroup = ""
        Exit function
    End If
    ForAll n In nabdoc.GetItemValue("Members")
        If Left$(n,3)= "CN=" Then
            Set uname = New NotesName(n)
            userlist(uname.Common) = uname.Common
        Else
            Set pview = nab.GetView("(LookupPeople)")
            Set pdoc = pview.GetDocumentByKey(CStr(n))
            If Not pdoc Is Nothing Then
                userlist(CStr(n)) = CStr(n)
            else
                tmplist = ExpandGroup(CStr(n))
                If IsList(tmplist) Then
                    ForAll t In tmplist
                        userlist(t) = t
                    End ForAll
                End If
            End If   
        End If
    End ForAll
    ExpandGroup = userlist
End Function

 

Dynamic tables in classic Notes

Posted on August 31, 2011 by Karl-Henry Martinsson Posted in Lotusscript, Notes/Domino, Old Blog Post, Programming 7 Comments

Using Xpages, you can do many neat things in Notes. But I am still doing all my development in classic Notes, despite being on Notes/Domino 8.5.2. The reason is simple. Memory. There is just not enough memory to run the standard client in our Citrix environment, so all users are using the basic client. And Xpages is not working in the basic client.

So how do I solve issues like multiple documents tied to a main document, being displayed inline in the main document? Well, I solved this a long time ago by using a rich text field and building the document list on the fly. I am sure many other Notes developers use this technique. I know it was discussed in a session at Lotusphere several years ago, perhaps as long ago as 7-8 years ago. So this is of course not anything I came up with myself.

In this post I just want to share how I am using this, and perhaps this can help someone.

The database (download it here) is very simple. It contains three (3) forms and two (2) views. In addition I have some icon as image resources, but that is just to make things pretty.

 

Forms

The ‘MainDoc’ form is the main document, being displayed in the view ‘By Last Change’. It contains a few fields:
‘Title’ – a text field where the user can enter a title/description
‘Data’ – a rich text field where the rendered table rows will be displayed
‘ParentUNID’ – a hidden computed-when-composed field where the UniversalID of the document is stored
‘EntryCount’ – a hidden text field used to count the number of entries (to display in the views)
‘LastEntry’ and ‘LastEntryDate’ – Hidden text fields to keep track of the last person who edded an entry
The form also contains some regular action buttons (‘Save’, ‘Edit’, ‘Close’), as well as ‘Add entry…’, an action button with two lines of Formula language:
@Command([FileSave]);
@Command([Compose];”Entry”)

image

The QueryOpen event, which executes before the form is opened in the front-end and displayed to the user, contains some Lotusscript code. This event let us modify the document in the backend, which is where rich text fields can be updated. The code – which I will post at the end of this article – is very simple, it is just over 50 lines of code.

 

The ‘Entry’ form is where the entries are created. It is set to let fields inherit values from the document it is created from, and contains a couple of fields, some action buttons and some Lotusscript code as follows:
‘ParentUNID’ – editable, default value is “ParentUNID”, to inherit the value from MainDoc
‘Created’ and ‘Creator’ – computed-when-composed to store date/time and user name of creator
‘ItemDate’, ‘Issue’ and ‘Action’ – user data fields.

The ‘Entry’ form contains the following Lotusscript code:

(Declarations)
Dim callinguidoc As NotesUIDocument
Dim callingdoc As NotesDocument

Sub Initialize
   Dim ws As New NotesUIWorkspace
   Set callinguidoc = ws.CurrentDocument
   If Not callinguidoc Is Nothing Then
      Set callingdoc = callinguidoc.Document
   End If
End Sub

Sub Terminate
   Dim ws As New NotesUIWorkspace
   If Not callingdoc Is Nothing Then
      Call ws.EditDocument(False,callingdoc)
   End If
   If Not callinguidoc Is Nothing Then
      Call callinguidoc.Close(True)
   End If
End Sub

The code simply store the calling document (MainDoc) in a global variable when being opened/created, and then force a save and reopen of it when closing. This will trigger the QueryOpen event in the MainDoc document to rebuild the rich text content.

The action button ‘Delete’ contains some code to flag the current document for later deletion. I normally do not allow users to delete document in production databases, instead I use a field to indicate that the document should be ignored in views and lookups. Later I run a scheduled agent to actually delete the flagged documents.

Sub Click(Source As Button)
   Dim ws As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
   Dim session As New NotesSession
   Dim doc As NotesDocument
   Dim unid As String
   Dim result As Integer

   result = Msgbox("Are you sure you want to delete this document?",_ 
   4+32,"Delete Document")
   If result = 7 Then
      Exit Sub
   End If
   Set uidoc = ws.CurrentDocument
   unid = uidoc.Document.UniversalID
   Call uidoc.Close(True)
   Set doc = session.CurrentDatabase.GetDocumentByUNID(unid)
   doc.flagDelete = "Yes"
   Call doc.Save(True, False)
End Sub

The final and last form is a repeat of the Entry form, but formatted the way you want each entry/row to be displayed in the rich text field. I call the form ‘RecTemplate’:

image

 

Views

In addition to the forms, there are two views. ‘By Last Change’ is just a normal view to display the documents based on the ‘MainDoc’ form. The other one is the one used by the code. It is a hidden view called ‘(LookupEntry)’. The first column is sorted (to allow lookups using col.GetAllDocumentsByKey() and contains the ParentUNID field. I have the column categorized as well, but that is really not needed. I also added two additional columns to make it easier for you as developer to look at the content. The view selection is as follows:
SELECT Form=”Entry” & flag_Remove=””

 

Lotusscript for QueryOpen on ‘MainDoc’ form

Finally the code that makes it all happen. The code simply perform a lookup in the view (LookupEntry) to get all entries associated with the current document and updates a few fields (mainly for view display purposes). The code then loop through the entries and for each entry creates a template document and render it into the rich text field. That is basically it.

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, _
    Continue As Variant)
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim col As NotesViewEntryCollection
    Dim entry As NotesViewEntry
    Dim entrydoc As NotesDocument
    Dim thisdoc As NotesDocument
    Dim datafield As NotesRichTextItem
    Dim templatedata As NotesRichTextItem
    Dim entrydata As NotesRichTextItem
    Dim doclink As NotesRichTextItem
    Dim template As NotesDocument
    Dim parentunid As String

    If source.IsNewDoc Then
        Exit Sub  ' Exit if new document, we do not have a ParentUNID or entries yet
    End If
    Set thisdoc = source.Document
    Set datafield = New NotesRichTextItem(thisdoc,"Data")
    parentunid = thisdoc.GetItemValue("ParentUNID")(0)
    Set db = session.CurrentDatabase
    Set view = db.GetView("(LookupEntry)")
    Set col = view.GetAllEntriesByKey(parentunid,True)
    Call thisdoc.ReplaceItemvalue("EntryCount",Cstr(col.Count))
    Set entry = col.GetFirstEntry
    If Not entry Is Nothing Then
       Call thisdoc.ReplaceItemvalue("LastEntryBy", _
       entry.Document.GetItemValue("Creator")(0))
       Call thisdoc.ReplaceItemvalue("LastEntryDate", _
       Format$(Cdat(entry.Document.GetItemValue("ItemDate")(0)),"mm/dd/yyyy"))
       Call thisdoc.Save(True,True)
   Else
       Call thisdoc.ReplaceItemvalue("LastEntryBy","")
       Call thisdoc.ReplaceItemvalue("LastEntryDate","")
       Call thisdoc.Save(True,True)
   End If 
   Do While Not entry Is Nothing
       Set entrydoc = entry.Document
       Set template = New NotesDocument(db)
       Call template.ReplaceItemValue("Form","RowTemplate")
       Call template.ReplaceItemValue("ItemDate", _
       Format$(Cdat(entrydoc.GetItemValue("ItemDate")(0)),"mm/dd/yyyy"))
       Call template.ReplaceItemValue("Creator", _
       entrydoc.GetItemValue("Creator")(0))
       Call template.ReplaceItemValue("Issue", _
       entrydoc.GetItemValue("Issue")(0))
       ' *** Copy Rich text Field "Issue"
       Set entrydata = entrydoc.GetFirstItem("Issue")
       Set templatedata = New NotesRichTextItem(template,"Issue")
       Call templatedata.AppendRTItem(entrydata)
       ' *** Copy Rich text Field "Action"
       Set entrydata = entrydoc.GetFirstItem("Action")
       Set templatedata = New NotesRichTextItem(template,"Action")
       Call templatedata.AppendRTItem(entrydata)
       ' *** Add doclink to entry
       Set doclink = New NotesRichTextItem(template,"DocLink")
       Call doclink.AppendDocLink(entrydoc,"Open Entry")
       Call template.ComputeWithForm(True,False)
       ' *** Refresh form
       Call template.RenderToRTItem(datafield)
       Set entry = col.GetNextEntry(entry)
   Loop
   Call thisdoc.ComputeWithForm(True,False)
End Sub

And this is what it looks like after adding three entries:

image

It is of course easy to change the sort order, field to use for sorting, etc.

 

Update: 2011-08-17 – Fixed download link.

 

Free Application Template/Framework for Notes

Posted on November 18, 2010 by Karl-Henry Martinsson Posted in IBM/Lotus, Notes/Domino, Old Blog Post, Programming 2 Comments

Many of my Notes application have a similar/the same look, based on a generic application template I created a while back.

The standard look makes the users feel at home when I deploy a new application, and the template makes life easier for me. If I create a new application based on that template, I already have the frameset, navigator and a few design element done before I even start the development.

Below is a screenshot of what it looks like in the Notes 8.5.2 client:

GenericTemplateScreenshot

 

I want to share the template with the Lotus community, as a small way of giving back.
I may add more things to it later, I will post any modifications here as well.

Click here to download the file.

Update: Download link fixed now.Thanks Hynek for pointing it out!

 

Agent Logging – Budget Style

Posted on November 10, 2010 by Karl-Henry Martinsson Posted in IBM/Lotus, Lotusscript, Notes/Domino, Programming Leave a comment

At my work, we had several issues/needs related to agents in different Domino databases. I tried to come up with a quick and lean solution, that gave us the functionality we needed, nothing more and nothing less. Yes, I am aware of Julian Robichaux’s excellent OpenLog. But we had some needs that I did not feel were addressed in that project.

What I wanted was a database where the agents could be documented, and also where the log data was stored. So I created a Agent Log database where one document is stored per agent. The form let me document the actions of the agent, as well as what server it is running on, in what database, when it is triggered, etc. When the document is opened, I also read the last time the agent was run and if the agent is enabled or not.

This is a sample document for an agent. It is scheduled to run at 11am every day:

AgentLog_Doc

 

This is what the actual database looks like.

AgentLog

I plan to release the database on OpenNTF.org when I get the time.

 

Nothing complicated this far. The next step was to create a small script library, doing the actual logging. I created a script library called Class.AgentLog with the following code:

Public Const THREAD_TICKS=6
Public Const THREAD_TICKS_PER_SEC=7

Class AgentLog
	Private session As NotesSession
	Private logdb As NotesDatabase
	Private agentdoc As NotesDocument   ' Main doc in Agent Log db
	Private logdoc As NotesDocument
	Private running As Integer
	Private tstart As Long              ' Ticks at start
	Private tend As Long                ' Ticks at end
	Private tps As Long                 ' Ticks per second (system dependant)
	
	Public Sub New( agentname As String )
		Dim view As NotesView
		Dim key As String
		running = True
		tstart = GetThreadInfo( THREAD_TICKS )
		tps = GetThreadInfo( THREAD_TICKS_PER_SEC )
		Set session = New NotesSession
		Set logdb = New NotesDatabase( session.CurrentDatabase.Server, "IT/AgentLog.nsf" )
		Set view = logdb.GetView( "(LookupAgent)" )
		If agentname = "" Then
			agentname = session.CurrentAgent.Name
		End If
		key = session.CurrentDatabase.FilePath & "~" & agentname
		Set agentdoc = view.GetDocumentByKey( key )
		If agentdoc Is Nothing Then
			Print "AgentLog: Failed to locate agent document for " & agentname & "."
			Exit Sub
		End If
		Set logdoc = New NotesDocument( logdb )
		logdoc.Form = "LogItem"
		Call logdoc.MakeResponse( agentdoc )
		Call logdoc.ReplaceItemValue("AgentName", agentname )
		Call logdoc.ReplaceItemValue("StartTime", Now() )
		If session.IsOnServer = True Then
			Call logdoc.ReplaceItemValue("RunBy", session.CurrentDatabase.Server )
		Else
			Call logdoc.ReplaceItemValue("RunBy", session.CommonUserName )
		End If
	End Sub
	
	Public Sub Finish()
		running = False
	End Sub
	
	Public Sub Terminate()
		Dim seconds As Integer
		If logdoc Is Nothing Then
			Exit Sub
		End If
		tend = GetThreadInfo( THREAD_TICKS )
		seconds = (tend - tstart) / tps
		Call logdoc.ReplaceItemValue("EndTime", Now() )
		Call logdoc.ReplaceItemValue("Seconds", seconds )
		If running = True Then ' Check if not terminated gracefully
			Call logdoc.ReplaceItemValue("Terminated", "Yes" )
		End If
		Call logdoc.Save(True,True)
	End Sub

End Class

All code goes in the (Declarations) section of the script library.
There are a few things to notice. I actually make each log item a child (response) document to the main document. By doing this, I can easily later create reports for each agent about all the times it was executed, etc.
When the object is instantiated, a blank string is normally passed. This will set the agent name variable to the actual agent name. The agent name is listed in the agent log document. If for some reason you want to use a different agent name in the document (e.g. the agent is a manually triggered agent called AdminUpdateSelectedDocuments and you want it listed just as UpdateSelectedDocuments).

 

The only thing left now is to update every agent you want to log as follows:

In the (Options) section:

Use "Class.AgentLog"

In the (Declarations) section:

Dim agent As AgentLog

In the Initialize event, I put one line at the beginning and one right at the end. The first line instantiate the agent log object and. set a flag indicating that the agent is running. The second line will clear that flag, so the final function knows that the agent ended gracefully.

Sub Initialize
 Set agent = New AgentLog("")
 ' *** Do stuff here
 Call agent.Finish()
End Sub

The last thing is to add one line to the Terminate event. This line is where the logging is actually done. If the flag running is set, we know the agent was terminated before it actually reached the end.

Sub Terminate
 Call agent.Terminate()
End Sub

Happy logging!

My Favorite Tools

Posted on April 29, 2010 by Karl-Henry Martinsson Posted in Notes/Domino, Programming, Utilities 2 Comments

Kathy Brown today asked “What’s Your Favorite Tool“, so I thought I wanted to share the tools I use.

My favorite tool is probably NoteMan from MartinScott. If I have to pick one tool from the suite, it would be either NoteMan.Editor or NoteMan.DocDelta. It is very hard to decide between the two of them. Editor is great for editing documents, see the contents of different fields and even change data types. I use it to get the UniversalID of documents and much more. DocDelta help me solve replication conflicts quickly and easy. I can higly recommend the NoteMan suite of tools to any Notes/Docmino developer, and for the price ($395 for the whole suite), you get a lot of functionality.

I also use several tools from TeamStudio and Ytria. Yes, I am lucky enough to have a boss who believe in getting me the tools I need.

From TeamStudio I use Undo (previously called Snapper) to make snapshots of the design while developing for easy roll-back, Profiler to find performance issues in my code and Configurator for search-and-replace through-out a database (design and/or documents). Those tools run around $500 each, if I recall correctly. I also use their free class browser, a tool I highly recommend to everyone doing object oriented Lotusscript development.

From Ytria I use a number of tools.The two I use the most are scanEZ and actionBarEZ. The latter is great when I want to apply a specific design of action bars to many forms and/or views. I design the action bar in one view, with colors, fonts, backgrounds, etc. When I am satisfied I can update all views and forms the the database with the new design. I don’t use scanEZ as much, but still on a regular basis. It also have functions to identify replication conflicts, like NoteMan.DocDelta, but the two tools complement each other. Using scanEZ, I can locate and delete documents of a particular type, including profile documents, and much more. I also sometimes use designPropEZ to check the design of a database and make sure it does not inherit element from the wrong templates/databases.

Here is a screenshot of my currect toolbar with all my development tools:

 

In addition I use Photoshop CS2 for graphics editing, TechSmith Jing to create screencam demos for managers/users, and Notepad++ for some HTML/Javascript/jQuery editing.

Stack Exchange

profile for Karl-Henry Martinsson on Stack Exchange, a network of free, community-driven Q&A sites

Recent Posts

  • Domino 14 is now available
  • Domino 14 Early Access Program
  • Announced: Engage 2024
  • Integrate Node-RED with Notes and Domino
  • Notes and Domino v12 is here!

Recent Comments

  • Theo Heselmans on Announced: Engage 2024
  • Lotus Script Multi-thread Message Box [SOLVED] – Wanted Solution on ProgressBar class for Lotusscript
  • Viet Nguyen on Keep up with COVID-19 though Domino!
  • Viet Nguyen on Keep up with COVID-19 though Domino!
  • Mark Sullivan on Looking for a HP calculator? Look no further!

My Pages

  • How to write better code in Notes

Archives

  • December 2023 (1)
  • October 2023 (2)
  • September 2023 (1)
  • June 2021 (1)
  • April 2021 (2)
  • March 2021 (1)
  • August 2020 (3)
  • July 2020 (2)
  • April 2020 (2)
  • March 2020 (1)
  • December 2019 (2)
  • September 2019 (1)
  • August 2019 (2)
  • July 2019 (2)
  • June 2019 (3)
  • April 2019 (2)
  • December 2018 (1)
  • November 2018 (1)
  • October 2018 (5)
  • August 2018 (2)
  • July 2018 (3)
  • June 2018 (2)
  • May 2018 (1)
  • April 2018 (2)
  • March 2018 (1)
  • February 2018 (2)
  • January 2018 (4)
  • December 2017 (3)
  • November 2017 (2)
  • October 2017 (2)
  • September 2017 (1)
  • August 2017 (2)
  • July 2017 (6)
  • May 2017 (4)
  • February 2017 (1)
  • January 2017 (2)
  • December 2016 (2)
  • October 2016 (3)
  • September 2016 (4)
  • August 2016 (1)
  • July 2016 (2)
  • June 2016 (2)
  • May 2016 (3)
  • April 2016 (1)
  • March 2016 (4)
  • February 2016 (2)
  • January 2016 (4)
  • December 2015 (3)
  • November 2015 (2)
  • October 2015 (1)
  • September 2015 (2)
  • August 2015 (1)
  • July 2015 (5)
  • June 2015 (2)
  • April 2015 (2)
  • March 2015 (3)
  • February 2015 (2)
  • January 2015 (10)
  • December 2014 (1)
  • November 2014 (3)
  • October 2014 (3)
  • September 2014 (13)
  • August 2014 (6)
  • July 2014 (5)
  • May 2014 (3)
  • March 2014 (2)
  • January 2014 (10)
  • December 2013 (5)
  • November 2013 (2)
  • October 2013 (5)
  • September 2013 (4)
  • August 2013 (7)
  • July 2013 (3)
  • June 2013 (1)
  • May 2013 (4)
  • April 2013 (7)
  • March 2013 (8)
  • February 2013 (9)
  • January 2013 (5)
  • December 2012 (7)
  • November 2012 (13)
  • October 2012 (10)
  • September 2012 (2)
  • August 2012 (1)
  • July 2012 (1)
  • June 2012 (3)
  • May 2012 (11)
  • April 2012 (3)
  • March 2012 (2)
  • February 2012 (5)
  • January 2012 (14)
  • December 2011 (4)
  • November 2011 (7)
  • October 2011 (8)
  • August 2011 (4)
  • July 2011 (1)
  • June 2011 (2)
  • May 2011 (4)
  • April 2011 (4)
  • March 2011 (7)
  • February 2011 (5)
  • January 2011 (17)
  • December 2010 (9)
  • November 2010 (21)
  • October 2010 (4)
  • September 2010 (2)
  • July 2010 (3)
  • June 2010 (2)
  • May 2010 (3)
  • April 2010 (8)
  • March 2010 (3)
  • January 2010 (5)
  • November 2009 (4)
  • October 2009 (7)
  • September 2009 (1)
  • August 2009 (7)
  • July 2009 (1)
  • June 2009 (4)
  • May 2009 (1)
  • April 2009 (1)
  • February 2009 (1)
  • January 2009 (3)
  • December 2008 (1)
  • November 2008 (1)
  • October 2008 (7)
  • September 2008 (7)
  • August 2008 (6)
  • July 2008 (5)
  • June 2008 (2)
  • May 2008 (5)
  • April 2008 (4)
  • March 2008 (11)
  • February 2008 (10)
  • January 2008 (8)

Categories

  • AppDev (10)
  • Blogging (11)
    • WordPress (5)
  • Design (5)
    • Graphics (1)
    • UI/UX (2)
  • Featured (5)
  • Financial (2)
  • Food (5)
    • Baking (3)
    • Cooking (3)
  • Generic (11)
  • History (5)
  • Hobbies (10)
    • LEGO (4)
    • Photography (4)
  • Humor (1)
  • IBM/Lotus (178)
    • #Domino2025 (14)
    • #DominoForever (8)
    • #IBMChampion (46)
    • Administration (7)
    • Cloud (7)
    • CollabSphere (9)
    • Community (49)
    • Connect (33)
    • ConnectED (12)
    • Connections (3)
    • HCL (15)
    • HCL Master (1)
    • IBM Think (1)
    • Lotusphere (46)
    • MWLUG (25)
    • Notes/Domino (99)
      • Domino 11 (7)
    • Sametime (8)
    • Verse (14)
    • Volt (3)
    • Watson (6)
  • Life (8)
  • Microsoft (7)
    • .NET (2)
    • C# (1)
    • Visual Studio (1)
  • Movies (3)
  • Old Blog Post (259)
  • Personal (23)
  • Programming (84)
    • App Modernization (11)
    • Formula (4)
    • Lotusscript (47)
    • NetSuite (4)
      • SuiteScript (3)
    • node.js (4)
    • XPages (4)
  • Reviews (9)
  • Sci-Fi (4)
  • Software (24)
    • Flight Simulator (2)
    • Games (4)
    • Open Source (2)
    • Utilities (6)
  • Technology (37)
    • Aviation (3)
    • Calculators (2)
    • Computers (6)
    • Gadgets (7)
    • Mobile Phones (7)
    • Science (3)
    • Tablets (2)
  • Travel (7)
    • Europe (1)
    • Texas (2)
    • United States (1)
  • Uncategorized (16)
  • Web Development (50)
    • Frameworks (23)
      • Bootstrap (14)
    • HTML/CSS (12)
    • Javascript (32)
      • jQuery (23)
  • Prev
  • 1
  • …
  • 16
  • 17
  • 18

Administration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Tracking

Creeper
MediaCreeper
  • Family Pictures
© TexasSwede 2008-2014