Coming Soon – IdeaExchange

IdeaExchange

This site will not only allow the community to drive future features that they would like to see in Notes/Domino/Samtime/Quickr etc. but will also be for Lotus ISV’s as well. I have discussed this concept with a half dozen or so Lotus ISV’s in they welcome the approach that we are striving to deliver.

Bruce Elgort

[more …]


Gantt Charts in Notes Views – The Sequel

Several gurus of the Lotus Notes community ( like Chris Blatnick, Nathan Freeman, Theo Heselmans, Vitor Pereira, and to round it out Kevin Pettitt ) are working on Gantt Charts in Notes Views these days. Nathan Freeman also provided a sample database.

I’ve downloaded the sample and gave it a try. The first thing I found out is that it is not possible to display more than one month in a view because the “zeroDate” – value for the columns is calculated by stripping the last part of the view title and convert it into a DateTime value. The sideeffect of this method is that documents from a different month are displayed in the view but no chart is displayed for these documents.
OK, you can avoid this by setting the view selction formula properly. The second thing is that Nathan uses

zeroDate :=@TextToTime(@Right(@ViewTitle; "-"));

in each of the 62 view columns to calculate the date basis. Maybe a bit ressource performance consuming, isn’t it ?

So I decided to make a few modifications to address these issues. I created a new field in the task form ( “zeroDate”, Date/Time, calculated )

Gantt Charts in Notes Views
and assigned the following formula to the field:

@TextToTime("[01/"+ @Text(@Month(startDate)) +"/"+ @Text(@Year(startDate)) + "]" )

When you create a new task, the zeroDate field is now set to the first day of the month according to the start date’s month.

You can now delete the unnecessary code from the column formulas and reduce it to

col := 0;
colDate := @Adjust(zeroDate; 0; 0; col; 0; 0; 0);
@If(@Date(startDate) = @Date(coldate); duration; " ")

After adding two categorized columns ( one contains @Year(StartDate) and the other one @Month(StartDate) ) the view displays the charts for each month in a seperate category.

Gantt Charts in Notes Views
The view can have any name of your choice.


ReportGenerator Class

Andre Guirard presents a class for creating rich-text reports and displaying them in a few different ways. It includes code to deal with the problem of paragraphs getting too long, and conversely, the problem of having too many paragraphs.

Basically, when you want to have a line break in your report, the class only starts a new paragraph if you specify it has to. Otherwise it uses line break, unless the paragraph is getting too long, in which case it starts a new paragraph.


Calculate Elapsed Time Between Two Date/Time Values

For my OpenNTF project !!HELP!! I needed a function to calculate the elapsed time between two events. The code should be able to exclude holidays and weekends. In addition it should calculate the time difference only within workhours. Here is the result of a rainy sunday 🙂
There is another class by Sean Burgess, which does the same stuff than mine.

The following sample returns the amount of time in minutes between two given date/time values

Sub Click(Source As Button)
	Dim startdt As String
	Dim enddt As String
	Dim dtc As New DateTimeCalculator ( "1,7","24.12.2007","7:00~17:00")

	startdt = "18.06.2007 16:59"
	enddt = "19.06.2007 07:01"

	Msgbox dtc.GetElapsedTime(startdt,enddt)
End Sub

Copy the following code to a script library. Type

Use "YourLibName"

into the Options section of your button, agent or whereever you like to use the lib. Don’t forget to include Julian Robichaux’s OpenLog for error trapping.

Class DateTimeCalculator

	Private StartDT As NotesDateTime
	Private EndDT As NotesDateTime
	Private dt3 As NotesDateTime
	Private dt4 As NotesDateTime
	Private dt5 As NotesDateTime
	Private WDENDHOUR As String
	Private WDSTARTHOUR As String
	Private nondays As String
	Private holidays As String

	Sub New (strExcludeDays As String,strExcludeDates As String,SERVICEHOURS As String)
		On Error Goto ERRHANDLE

		WDSTARTHOUR = "00:00"
		WDENDHOUR = "23:59"
		nondays = "0"
		holidays = "[01/01/1899]"

		If SERVICEHOURS <> "" Then
			WDSTARTHOUR = Strtoken(SERVICEHOURS,"~",1)
			WDENDHOUR = Strtoken(SERVICEHOURS,"~",2)
		End If
		If strExcludeDays <> "" Then
			nondays = Implode(Split(strExcludeDays,","),":")
		End If
		If strExcludeDates <> "" Then
			holidays = Implode(Split(strExcludeDates,","),"]:[")
			holidays = "[" & holidays & "]"
		End If

EXITPOINT:
		Exit Sub
ERRHANDLE:
		Call LogError()
		Resume EXITPOINT
	End Sub

	Public Function GetNextBusinessDay (dt1 As String) As String
		On Error Goto ERRHANDLE
		Dim newDT As Boolean
		Set Me.StartDT = New NotesDateTime(dt1)
		NewDt = False
		Set dt3 = New NotesDateTime(Me.StartDT.DateOnly & " " & Me.WDSTARTHOUR)
		Set dt4 = New NotesDateTime(Me.StartDT.DateOnly & " " & Me.WDENDHOUR)
		If Me.StartDT.TimeDifference(dt3) < 0 Then ' StartDT < WDSTARTHOUR
			Set Me.StartDT = dt3
		End If

		If dt4.TimeDifference(Me.StartDT) < 0 Then ' StartDT > WDENDHOUR
			Set Me.StartDT = dt3
			Call Me.StartDT.AdjustDay(1)
		End If

		While Me.GetBusinessDays (StartDT.DateOnly,StartDT.DateOnly ) = 0
			Call StartDT.AdjustDay(1)
			NewDT = True
		Wend

		If NewDT Then
			Set dt5 = New NotesDateTime(Me.StartDT.DateOnly & " " & Me.WDSTARTHOUR)
			Set Me.StartDT = dt5
		End If

		GetNextBusinessDay = Me.StartDT.LocalTime

EXITPOINT:
		Exit Function
ERRHANDLE:
		Call LogError()
		Resume EXITPOINT
	End Function

	Private Function GetNumBusinessDayHours () As Integer
		On Error Goto ERRHANDLE
		Dim BDHOURS1 As New NotesDateTime(Today & " " & Me.WDSTARTHOUR)
		Dim BDHOURS2 As New NotesDateTime(Today & " " & Me.WDENDHOUR)
		GetNumBusinessDayHours = Fix(((BDHOURS2.TimeDifference(BDHOURS1)/60)Mod 1440)/60)

EXITPOINT:
		Exit Function
ERRHANDLE:
		Call LogError()
		Resume EXITPOINT
	End Function

	Private Function GetTimeDifference (strStart As String,strEnd As String ) As Long
		On Error Goto ERRHANDLE
		Dim BDSTART As New NotesDateTime(strStart)
		Dim BDEND As New NotesDateTime(strEnd)
		GetTimeDifference = Fix((BDEND.TimeDifference(BDSTART)/60)Mod 1440)

EXITPOINT:
		Exit Function
ERRHANDLE:
		Call LogError()
		Resume EXITPOINT
	End Function

	Public Function GetBusinessDays(dtStart As String,dtEnd As String) As Integer
		On Error Goto ERRHANDLE
		Dim busdays As Variant

		Dim BDS As New NotesDateTime(dtStart)
		Dim BDE As New NotesDateTime(dtEnd)

		busdays = Evaluate(_
		{@BusinessDays([}&_
		Cdat(BDS.DateOnly)& {];[}&_
		Cdat(BDE.DateOnly)& {];}&_
		Me.nondays &{;}&_
		Me.holidays & {)})
		GetBusinessDays = Cint(busdays(0))

EXITPOINT:
		Exit Function
ERRHANDLE:
		Call LogError()
		Resume EXITPOINT
	End Function

	Public Function GetElapsedTime (dtStart As String,dtEnd As String) As Long
		On Error Goto ERRHANDLE
		Dim intStart As Long
		Dim intMiddle As Long
		Dim intEnd As Long
		Dim i As Integer

		Set dt3 = New NotesDateTime(dtStart)
		Set dt4 = New NotesDateTime(dtEnd)
		If dt3.DateOnly = dt4.dateonly Then ' same day
			GetElapsedTime = Me.GetTimeDifference(dtStart,dtEnd)
		Else
			intStart = Me.GetTimeDifference(dtStart,Cstr(dt3.DateOnly & " " & Me.WDENDHOUR))
			intMiddle = 0
			i = Me.GetBusinessDays(dtStart,dtEnd)-2
			If i > 0 Then
				intMiddle = (i*Me.GetNumBusinessDayHours())*60
			End If
			intEnd = Me.GetTimeDifference(Cstr(dt4.DateOnly & " " & Me.WDSTARTHOUR),dtEnd)
			GetElapsedTime = intStart+intMiddle+intEnd
		End If

EXITPOINT:
		Exit Function
ERRHANDLE:
		Call LogError()
		Resume EXITPOINT
	End Function
End Class

Adjust Date/Time To Next Business Day – Part II

In my recent posting I showed a method to calculate the number of business days between one date and another. It is possible to exclude weekends and a list of dates, too.
How to adjust Date/Time to next business day, I’ve already described here.

When using the GetBusinessDays method from my recent posting, the code to adjust a date to the next business day can be reduced to at least this snippet:

Sub Click(Source As Button)
	Dim dtStart As String
	Dim dtEnd As String
	dtStart = Today
	dtEnd = dtStart

	Dim b As New BusinessDay("1:7","[18.06.2007]:[19.06.2007]:[20.06.2007]")
	Dim StartDT As NotesDateTime

	Set StartDT = New NotesDateTime (dtStart)
	While b.GetBusinessDays (dtStart,dtEnd ) = 0
		Call StartDT.AdjustDay(1)
		dtEnd = StartDT.DateOnly
	Wend

	Msgbox StartDT.DateOnly
End Sub

This is a great example of how evaluating @formulas in LotusScript can save you a lot of time when you want to write a function which is not available in Script.


@BusinessDays In LS

In R6 you can use @BusinessDays to calculate the number of working days between one date and another, excluding non-working days and a list of dates to exclude as well. As there is no equivalent in LotusScript, I wrote a small class to simulate @BusinessDays in LS.
Actually I did not reinvent the wheel, but simply used evaluate in combination with @BusinessDays to achieve the aim.

Here is my code:

Class BusinessDay

	Private holidays As String
	Private nondays As String

	Sub New (strExcludeDays As String,strExcludeDates As String)
		holidays = "[01/01/1899]"
		nondays = "0"
		If strExcludeDays <> "" Then
			nondays = strExcludeDays
		End If

		If strExcludeDates <> "" Then
			holidays = strExcludeDates
		End If
	End Sub

	Public Function GetBusinessDays(dtStart As String,dtEnd As String) As Integer

		Dim bd As Variant
		Dim StartDT As New NotesDateTime(dtStart)
		Dim EndDT As New NotesDateTime(dtEnd)

		GetBusinessDays = 0
		bd = Evaluate({@BusinessDays([}&_
		Cdat(StartDT.DateOnly)& {];[}&_
		Cdat(EndDT.DateOnly)& {];}&_
		Me.nondays &{;}&_
		Me.holidays &_
		{)})
		GetBusinessDays = Cint(bd(0))
	End Function

End Class

To test the code, put the code into the declaration section of a button. In your “Click” event type

Sub Click(Source As Button)
	Dim dtStart As String
	Dim dtEnd As String
	dtStart = "05.06.2007"
	dtEnd = "11.06.2007"

	'Dim b As New BusinessDay("1:7","[08.06.2007]:[06.06.2007]:[07.06.2007]")
	'Dim b As New BusinessDay("","[08.06.2007]:[06.06.2007]:[07.06.2007]")
	Dim b As New BusinessDay("","")
	Msgbox b.GetBusinessDays (dtStart,dtEnd )
End Sub

SuperNTF – Beta 0.9.4 released

Kevin Pettitt released version 0.9.4 of SuperNTF on OpenNTF.

SuperNTF by Kevin Pettitt

The initial release of SuperNTF is full of goodies. The first thing you will see is the clean navigation framework. Give yourself the “Admin” role and you will see a link to the “Administration” panel, where all sorts of configuration and logging functions are visible.

You should click the “DB Config” item under “Configuration” to change some global database properties. Check out the other configuration options, and note the “code helpers” which build formula syntax for using keyword and other formulas automatically.

I highly recommend keeping soft deletions enabled, as it works VERY well, regardless of how you delete documents (including “cuts”). Also note the mouseover behavior of the trash icon (and several others).

If you write any agents, check out the “Agent Templates” which provide a couple different common agent frameworks. Note that these samples include the standard OpenLog error trapping elements.

The standard “view actions” are highly tuned to show/hide as appropriate. E.g. the “Search” button only shows if the db is full text indexed. Also visible (only on windows) are the excel export actions.

All read and edit activity is tracked, so if you want to know what you looked at yesterday, check the “My History” view. To see what your boss read yesterday, look in the “User Activity” views in the Administration section. You can also see the history of specific field value changes at the document level.

And much more…


Adjust Date/Time To Next Business Day

Finding the difference in seconds between one date-time and another can be done using the timedifference method of the NotesDateTime class in LotusScript. In formula language, @BusinessDays returns the number of business days in one or more date ranges.
Assume you have the following requirements:

  • Calculate the time in minutes between “DateCreated” and “DateClosed”.
  • Businessdays are from Monday to Friday
  • BusinessHours ar from 8 AM to 10 PM
  • Exclude holidays
  • If the date/time value is greater than the end of a businessday, set date to next businessday
  • if the date/time value is before the beginning of a businessday, set the time to i.e 8 AM

Here is a LotusScript class which does the trick.

Class DateTimeCalculator

	Private StartDT As NotesDateTime
	Private EndDT As NotesDateTime
	Private dt3 As NotesDateTime
	Private dt4 As NotesDateTime
	Private dt5 As NotesDateTime
	Private NewDT As Boolean
	Private tmp As Variant
	Private i As Integer
	Private j As Integer
	Private k As Integer
	Private x As Integer
	Private elapsed As Integer
	Private ExcludeDays() As String
	Private ExcludeDates() As NotesDateTime
	Private WDENDHOUR As String
	Private WDSTARTHOUR As String

	Sub New (strExcludeDays As String_
                       , strExcludeDates As String_
                       , strWDSTARTHOUR As String_
                       , strWDENDHOUR As String)

		If strWDSTARTHOUR = "" Then
			WDSTARTHOUR = "00:00"
		Else
			WDSTARTHOUR = strWDSTARTHOUR
		End If

		If strWDENDHOUR = "" Then
			WDENDHOUR = "23:59"
		Else
			WDENDHOUR = strWDENDHOUR
		End If

		' strExcludeDays contains a comma separated list of dayes that are not work days
		tmp = Split(strExcludeDays,",")
		Redim Me.ExcludeDays(Ubound(tmp))
		For x = 0 To Ubound(tmp)
			Me.ExcludeDays(x) = tmp(x)
		Next

		' strExcludeDates contains a comma separated list of dates that are not work days
		tmp = Split(strExcludeDates,",")
		Redim Me.ExcludeDates(Ubound(tmp))
		For x = 0 To Ubound(tmp)
			Set Me.ExcludeDates(x) = New NotesDateTime(tmp(x))
		Next
	End Sub

	Public Function GetNextBusinessDay ( dt1 As String )As String
		Set Me.StartDT = New NotesDateTime (dt1)
		NewDt = False
		Set dt3 = New NotesDateTime (Me.StartDT.DateOnly & " " & Me.WDSTARTHOUR)
		Set dt4 = New NotesDateTime (Me.StartDT.DateOnly & " " & Me.WDENDHOUR)
		If Me.StartDT.TimeDifference(dt3) < 0 Then ' StartDT < WDSTARTHOUR
			Set Me.StartDT = dt3
		End If

		If dt4.TimeDifference(Me.StartDT) < 0 Then ' StartDT > WDENDHOUR
			Set Me.StartDT = dt3
			Call StartDT.AdjustDay(1)
		End If

		For j = 0 To Ubound ( Me.ExcludeDates ) ' Check for excluded dates
			For k = 0 To Ubound ( Me.ExcludeDates )
				If Me.StartDT.DateOnly = Me.ExcludeDates(k).DateOnly Then
					Call Me.StartDT.AdjustDay(1)
					NewDT = True
					For i = 0 To Ubound ( Me.ExcludeDays ) ' Check if businessday
						If Instr(Implode ( Me.ExcludeDays )_
                                                    , Cstr(Weekday(Me.StartDT.DateOnly))) > 0 Then
							Call Me.StartDT.AdjustDay(1)
						End If
					Next
					k = Ubound(Me.ExcludeDates)
				Else
					For i = 0 To Ubound ( Me.ExcludeDays ) ' Check if businessday
						If Instr(Implode ( Me.ExcludeDays _
                                                    ), Cstr(Weekday(Me.StartDT.DateOnly))) > 0 Then
							Call Me.StartDT.AdjustDay(1)
							NewDT = True
						End If
					Next
				End If
			Next
		Next

		If NewDT Then
			Set dt5 = _
                          New NotesDateTime (Me.StartDT.DateOnly & " " & Me.WDSTARTHOUR)
			Set Me.StartDT = dt5
		End If
		GetNextBusinessDay = Me.StartDT.LocalTime
	End Function

End Class

This class has a New function that is used to instantiate the class. A list of business days, list of holidays and the start and end of the workday is passed when the object is created.

	Dim DTCalc As New DateTimeCalculator ( "1,7", "11.06.2007","08:00", "22:00")

Once instatiated you can now adjust a date/time value to the next business by calling the GetNextBusinessDay method and passing the date/time value as a string parameter.

	StartDT = doc.GetFirstItem("DateCreated").text
         ...
        Set dt1 = New NotesDateTime ( DTCalc.GetNextBusinessDay(StartDT) )

The returned value can now be used to find the difference between this date/time value and another one.

	diff = dt2.TimeDifference(dt1)/60

Here is an example of how to put this all together in a click button. I have attached a sample database at the end of this article.

Sub Click(Source As Button)
	Dim s As New NotesSession
	Dim db As NotesDatabase
	Dim col As NotesDocumentCollection
	Dim doc As NotesDocument
	Set db = s.CurrentDatabase
	Set col = db.UnprocessedDocuments
	Set doc = col.GetFirstDocument

	Dim msg As String
	Dim StartDT As String
	Dim EndDT As String
	Dim dt1 As NotesDateTime
	Dim dt2 As NotesDateTime
	Dim diff As Long

	StartDT = doc.GetFirstItem("DateCreated").text
	EndDT = doc.GetFirstItem("DateClosed").text

	Dim DTCalc As New DateTimeCalculator ( "1,7", "11.06.2007","08:00", "22:00")

	Set dt1 = New NotesDateTime ( DTCalc.GetNextBusinessDay(StartDT) )
	Set dt2 = New NotesDateTime ( DTCalc.GetNextBusinessDay(EndDT) )

	diff = dt2.TimeDifference(dt1)/60
	msg = msg  & "Created On : " & StartDT & CRLF
	msg = msg  & "Closed On : " & EndDT & CRLF
	msg = msg & "Difference : " & diff & " minutes"
	Msgbox msg
End Sub

Download SampleDB


!!HELP!! and ExtND

Today I built in the ExtND framework into the !!HELP!! database. Without digging to deep into the framework, I was able to create a simple web interface for the helpdesk. Unfortunately, the framework does not support categorized views at the moment.

But this doesn’t matter. It is an Alpha release. But it already produces nice looking grid views with navigation and stuff. and works as expected in Firefox and IE.

!!HELP!! - ExtND

The next release of !!HELP!! will include the ExtND framework along with a handful of views and forms to enable end-users to watch the progress of their service calls on the web.

I would like to thank all who contributed to the !!HELP!! project. If you, as an end-user, would like to write a testimonial, you can do so here


The Day Before ILUG2007

Just returned from the lobby of the Alexander Hotel in Dublin, Ireland. Loads of geeks already there from mostly the U.S.A and Canada. Attached you find a photo taken while Kitty, Eileen and a Scotsman named Bill preparing some secret stuff for tomorrows event.

Final Preparations