Wednesday, March 25, 2009

Creating a Bookmark Icon for Your Domino Website

We all see those little icons next to your Favorite/Bookmark websites in your browser. Pretty cool, huh?

Here are the steps to make your own Bookmark Icon for your Domino website/application.

1. Create your graphic/logo and don't worry about the 16 x 16 pixel limit
2. Open this website:
http://www.html-kit.com/favicon/
3. This website will allow you to upload your graphic and it will size it to the 16 x 16 pixel limit
4. Follow the instructions to upload your graphic
5. When the "shrunk" graphic appears, follow the instructions on the screen and download the .zip file that is created.
6. Extract the "favicon.ico" file from the zip file
7. Open your database in Domino Designer
8. Add this .ico file to the Shared Resource > Files
9. Add the following code to each Form's HTML Head Content (NOTE: Replace the "[]" with "<>" --- blog would not post with the "<>", thought it was actual HTML):
"[link rel=\"shortcut icon\" href=\"/" + @WebDbName + "/favicon.ico?OpenFileResource\"]"
10. Test it out!

I have tested this in IE 6x and Firefox 3.0.x, using Domino Designer 7.x and it works fine.

What about adding to the Shared Resources > Images?
Glad you asked that... In Domino Designer 7 (and 6 and 5), you can only add .jpg, .gif, or .bmp types. So, add to the File Resources and you get the end result you wanted.

Hope this helps...

Tuesday, February 17, 2009

Determining the Week of the Year

I was recently asked to create a time tracking application. One of the issues I ran into was determining what week number of the year it was when creating the timesheet.

There is no @Week in formula language and no Week function in LotusScript. There were a couple ideas in JavaScript, but wanted to put it into LotusScript.

So, I came up with the idea of passing a date, formatted as a string, and finding which week it fell in.

Here is the function:

Function atWeek(weekDate As String) As Integer

Dim checkDate As NotesDateTime
Dim firstADate As NotesDateTime
Dim beginWeek As NotesDateTime
Dim endWeek As NotesDateTime
Dim message As String
Dim currentYear As String
Dim firstDay As String
Dim dayOfWeek As Integer
Dim addDays As Integer
Dim x As Integer
Dim dayCounter As Integer
Dim monthCounter As Integer

'Set the globals...
Const months = 12
Const weeks = 53 '365 Days / 7 Days a week = 52.14
Const weekdays = 7
Const dayOne = "01/01/"
currentYear = Year(Today)
firstDay = dayOne & currentYear

'Set the dates...
Set checkDate = New NotesDateTime(weekDate)
Set firstDate = New NotesDateTime(firstDay)

'Get the first week...
dayOfWeek = Weekday(firstDay)
addDays = weekdays - dayOfWeek

'Set the begin/end dates...
Set beginWeek = New NotesDateTime(firstDate.DateOnly)
'Increase the date...
firstDate.AdjustDay(addDays)
Set endWeek = New NotesDateTime(firstDate.DateOnly)

'Let's see if the date falls between first week...
If beginWeek.LSLocalTime <= checkDate.LSLocalTime Then If endWeek.LSLocalTime => checkDate.LSLocalTime Then
'We have a winner...
atWeek = 1
Exit Function
End If
End If

'We have the first week, let's get the next...
'Start with the second week, since we have the first week...
For x = 2 To weeks
'Increase the dates...
endWeek.AdjustDay(1)
Set beginWeek = New NotesDateTime(endWeek.DateOnly)
endWeek.AdjustDay(6)
Set endWeek = New NotesDateTime(endWeek.DateOnly)
'Let's see if the date falls between...
If beginWeek.LSLocalTime <= checkDate.LSLocalTime Then If endWeek.LSLocalTime => checkDate.LSLocalTime Then
'We have a winner...
atWeek = x
Exit Function
End If
End If
Next

End Function


Yes, I know I have 53 as the total weeks, but to do this based on a calendar year, there are 53 weeks. If you run 12/31/2009 through this function, 53 is returned.

It's a good little function, hopefully it will help you.

Tuesday, September 16, 2008

Finding and flagging "orphan" documents

A recent project that I was on had an issue with a user who happened to copy documents and paste them back into the database and then delete the original --- as quoted, the user said "the database was slow, so I was trying to shake things up."

Well, little did this user know that these were documents that had children/response documents associated with them. Now that the parent/child relationship was broken, the users were not too happy about this.

First, I had to find all the orphan docs before I associated them. So I wrote this little function which worked out pretty well:

Function IsOrphan(docResponse As NotesDocument) As Integer

Dim s As New NotesSession
Dim db As NotesDatabase
Dim docParent As NotesDocument
Dim docUNID As String
Dim parentUNID As String
Dim parentUNIDLength As Integer

Set db = s.CurrentDatabase
IsOrphan = False

'Check to see if this doc is really a response...
If docResponse.IsResponse Then
Else
Exit Function
End If

parentUNID = docResponse.ParentDocumentUNID
parentUNIDLength = Len(parentUNID)

Select Case parentUNIDLength
Case 32
Set docParent = db.GetDocumentByUNID(parentUNID)
If docParent Is Nothing Then
IsOrphan = True
Else
'Is the doc valid?
If docParent.IsValid = True Then
'See if this doc is a deletion stub...
If docParent.IsDeleted = True Then
IsOrphan = True
Else
docUNID = docParent.UniversalID
'Check to see if they are the same... [idiot check]...
If docUNID = parentUNID Then
Else
IsOrphan = True
End If
End If
Else
'Not valid...
IsOrphan = True
End If
End If

Case 1 To 31
'Parent UNID is not a UNID...
IsOrphan = True

Case 0
'Response, but no Parent UNID...
IsOrphan = True

End Select

End Function

Thought I would share this...