GetAllEntriesByKey and dates

Hi, I have a WebQuerySave agent where I’m trying to validate some data entry in a view. Basically, I’m wanting to check if there’s a date listed in a view, then I want to print an error message. Basically, the error is not occurring, and its processing the entry. My view column is sorted, ascending in a “general” format, so I can capture the datelist as a String. Why am I not erroring out when I plug in a date string that’s already in the view?

Dim session As New NotesSession

Dim db As NotesDatabase

Dim viewdate As NotesView

Dim vc2 As NotesViewEntryCollection

Dim DateListStart As String

’ now I get all the entries for the next collection

Set viewdate = db.GetView("XXX")	

Set vc2 = viewdate.GetAllEntriesByKey(DateListStart,False)	







If vc2.Count > 0 Then

	doc.WebMessage = "xxxx."

	Print printmsg

	Exit Sub

End If

Subject: GetAllEntriesByKey and dates

In your example code, DateListStart is never set to anything - it is simply declared as a string. Did you post the entire code?

Subject: RE: GetAllEntriesByKey and dates

Let’s try this again, and TIA!

Dim session As New NotesSession

Dim db As NotesDatabase

Dim viewdate As NotesView

Dim vc2 As NotesViewEntryCollection

Dim DateListStart As String

Dim printmsg As String

Set db=session.CurrentDatabase

Set doc = session.DocumentContext	

'now I build another key

DateKey(1) = doc.DateListStart(0)

’ now I get all the entries for the next collection

Set viewdate = db.GetView(“XXX”)

Set vc2 = viewdate.GetAllEntriesByKey(DateListStart,False)

If vc2.Count > 0 Then

doc.WebMessage = “xxxx.”

Print printmsg

Exit Sub

End If

Subject: RE: GetAllEntriesByKey and dates

Hi Wesley,

Perhaps you mean:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim viewdate As NotesView

Dim vc2 As NotesViewEntryCollection

Dim DateListStart As String

Dim printmsg As String

Set db=session.CurrentDatabase

Set doc = session.DocumentContext

’ now I get all the entries for the next collection

Set viewdate = db.GetView(“XXX”)

Set vc2 = viewdate.GetAllEntriesByKey(CStr(doc.DateListStart(0)),False)

If vc2.Count > 0 Then

doc.WebMessage = “xxxx.”

Print printmsg

Exit Sub

End If

although I’m not sure why you would want to lose date information by converting it to string in both the view and the lookup.

Subject: RE: GetAllEntriesByKey and dates

I wish I could say that worked, but its not. The reason I’m having to convert the dates to a string is because I’m using @Explode on the form to string out a list of dates with the following formula:

@Explode(@TextToTime(@Text(StartDate) + “-” + @Text(@Adjust(EndDate;0;0;-1;0;0;0))))

This is the formula for the “DateListStart” field, which I’m using as my key.

Subject: RE: GetAllEntriesByKey and dates

Try using an @Trim in the view as well as a trim in the script. There may be a rogue space in there somewhere.

Subject: RE: GetAllEntriesByKey and dates

Ok, I’ve added Trim to both the view column and the agent, and no success. Everything else look OK? I’m puzzled.

Subject: RE: GetAllEntriesByKey and dates

Try to setup some temp variables in your script and check exactly what is being passed in the debugger.

ie.

temp1 = CStr(doc.DateListStart(0))

Grab the contents of the temp1 variable and compare it to what is actually in the view.

Quick Question… Is the view you’re searching sorted?

Subject: RE: GetAllEntriesByKey and dates

what’s the best way to do the debugging when its a WebQuerySave agent?

Yes, the 1st column in the view is sorted.

Subject: RE: GetAllEntriesByKey and dates

To debug in a WebQuerySave you can MsgBox and the value will appear in the server’s log.nsf.

Also, I was going to suggest earlier (but got tied up with other stuff), you might want to use Format instead of CStr (I know I had suggested CStr previously, but Format will give you greater control).

Also, you still have the option of storing the exploded values as an array of dates by the simple modification:

@TextToTime(@Explode(@TextToTime(@Text(StartDate) + “-” + @Text(@Adjust(EndDate;0;0;-1;0;0;0)))))

Lastly, if all else fails, you can force a format on both the column value and the search value, for example:

x := @TextToTime(@Explode(@TextToTime(@Text(StartDate) + “-” + @Text(@Adjust(EndDate;0;0;-1;0;0;0)))));

@Text(@Year(x)) + “.” + @Right(“0” + @Text(@Month(x)); 2) + “.” + @Right(“0” + @Text(@Day(x)); 2);

The above will create your date list in the format “yyyy.mm.dd” within the multi-value date field, while the Format statement below achieves the same for the search:

Format(doc.DateListStart(0), “yyyy.mm.dd”)

Lastly, I hope that the field DateListStart has been declared as multi-value or else you will explode the date list but upon saving, the field will become one long string of semicolon separated values and of course no search against that column will succeed.