views:

324

answers:

2

Hi,

I'm trying to use the current day in GetAllEntriesByKey by passing an array. The array so far looks like this

Dim keyarray(2) As Variant  
keyarray(0) = "FF Thompson ADT"  
Set keyarray(1) = dateTime

I would like to say this

Set vc = view.GetAllEntriesByKey(keyarray, False)

Here is a row of what it looks like when it works. The test agent prints out csv in an email.

FF Thompson ADT,2/3/2009,11:45:02 PM,0,6,0,,00:00:04,5400,4

I can't seem to pass a current day dateTime that runs. I can set the dateTime manually in the declaration and it works. I think it's because it's trying to also pass the time but I don't know. I have tried three ways and it says invalid key value type.

Dim dateTime As New NotesDateTime("")
Call dateTime.LSLocalTime = Now
...
keyarray(1) = dateTime.Dateonly

Dim dateTime As New NotesDateTime("")
Call dateTime.SetNow
...
keyarray(1) = dateTime.Dateonly

Dim dateTime As New NotesDateTime("Today")
...
keyarray(1) = dateTime.Dateonly

I don't know if this is useful but I read about Evaluate here.

What I'm ultimately trying to do is GetFirstEntry for "FF Thompson ADT" for the most recent day entries exist. I'm also trying to do the same for the day before that. I'm trying to sum up the files processed (the number 6) for both days and errors (the null) for the most recent day using something like this. I need to tweak it so it finds the files processed and errors for entries but I haven't gotten there but should be able to do. I'm also just trying to find the most recent date with time value for the feed ie "FF Thompson ADT".

Set entry = vc.GetFirstEntry
filesprocessed = 0
Dim errors, errortotal As Integer
errors = 0
errorstotal = 0
While Not entry Is Nothing
  rowval = 0
  errors = 0
  Forall colval In entry.ColumnValues
    If rowval > 0 Then
      errors = Cint(colval)
    Else
      rowval = Cint(colval)
    End If
  End Forall
  filesprocessed = filesprocessed + rowval
  errorstotal = errorstotal + errors
  Set entry = vc.GetNextEntry(entry)
Wend

Thanks for any help or suggestions. They are greatly appreciated.

+1  A: 

Hi Todd,

I've only used the GetAllEntriesByKey method with an array of strings. I've never tried mixing types. But assuming differing types are valid for that method, the problem might lie in the difference between datetime types in Notes. There's a core LS datetime type and then there's a NotesDateTime object. I'd bet the view considers a date column to be made up of the core datetime types, and so it fails when you pass the NotesDateTime type.

But that issue aside, my suggestion is to create a view that has the columns you want to access, and set the sort order of the first column (containing FF Thompson ADT) to asc, then set the second column with your dates to desc. You can then access the view entries in the order you want, with the most recent being first, 2nd most recent 2nd, etc.

If by some chance the GetAllEntriesByKey method returns the documents out of order (I forget if it guarantees order), I know I've done this before using the NotesViewNavigator class. There's definitely an alternate way to do it without need to call GetAllEntriesByKey with the date key.

Ken Pespisa
Hi Ken,Thanks for the input. When I woke up I thought of passing the new notesdatetime object today's date as a string.Dim todaysdate As New NotesDateTime("Today")Dim dateTime As New NotesDateTime(todaysdate.DateOnly)This works!
Todd
Yeah I know the view is messy to work with but I was using a customized view before but it's too slow and resource intensive. Now I'm thinking of wrapping the GetAllEntriesByKey with an if statement asking to continually try yesterday's date if the entry returns a null.
Todd
Ah yeah I got it all done :)
Todd
+1  A: 

Here's an answer I found

Dim todaysdate As New NotesDateTime("Today")
Dim dateTime As New NotesDateTime(todaysdate.DateOnly)

Dim keyarray(1) As Variant keyarray(0) = feedname
Set keyarray(1) = dateTime 

Set vc = view.GetAllEntriesByKey(keyarray, False)
Todd
Sorry I wasn't more specific.Dim todaysdate As New NotesDateTime("Today")Dim dateTime As New NotesDateTime(todaysdate.DateOnly)Dim keyarray(1) As Variantkeyarray(0) = feednameSet keyarray(1) = dateTime
Todd