DB Search using Lotusscript

Hi All,

Im trying to perform a search using script but am getting the error Query Not Understandable. The ultimate goal is to generate an excel spreadsheet once I get documents in my document collection. Can anyone tell me where is the error. The dc.Count is not printing anything and in the log i get the error:

“06/21/2005 10:36:21 AM Agent ‘SearchExcel’ error: Notes error: Query is not understandable (Form = “Tasks” & Subject= & MailFrom=[boissy] & Urgency= & Date=>[ ] & EDate=<[ ])”

Dim Session As New NotesSession

Dim db As NotesDatabase

Set db=Session.CurrentDatabase



If ( db.LastModified > db.LastFTIndexed ) Then

	Call db.UpdateFTIndex ( False )

End If



Dim fromstr As String

Dim bodystr As String

Dim prioritystr As String

Dim subjectstr As String

Dim startdate As String

Dim enddate As String



Dim doc As NotesDocument

Set doc=Session.DocumentContext





fromstr=doc.MailFrom(0)

prioritystr=doc.Urgency(0)

subjectstr=doc.Subject(0)

startdate=doc.Date(0)

enddate=doc.EDate(0)



Dim dc As NotesDocumentCollection





Dim searchstring As String



searchstring = |Form = "Tasks" & Subject=[| & subjectstr & |] & MailFrom=[| & fromstr & |] & Urgency=[| & prioritystr & |] & Date=>[ | & startdate & | ] & EDate=<[ | & enddate & | ]|







Set dc = db.FTSearch(searchstring, 0)

Dim c As Integer

c=dc.Count

Print c

Thanks in Advance,

Ki

Subject: DB Search using Lotusscript

Your problem probably starts here:

Subject=[| & subjectstr & |]

Those square brackets you’re using? They won’t work. Square brackets are not used to delimit strings in a formula. Replace them with double quotes like the ones you’ve got around “Tasks”, except for the ones around the date fields, which you might want to put hash marks around (#) if the fields actually hold dates.

Subject: RE: DB Search using Lotusscript

Thanks for the reply. I have removed the date fields and added quotes like you suggested but even then its giving me the same error.06/21/2005 10:55:08 AM Agent ‘SearchExcel’ error: Notes error: Query is not understandable (Form = “Tasks” & Subject=“test” & MailFrom=“boissy” & Urgency=“P1”)

My code now looks like:

Dim Session As New NotesSession

Dim db As NotesDatabase

Set db=Session.CurrentDatabase



If ( db.LastModified > db.LastFTIndexed ) Then

	Call db.UpdateFTIndex ( False )

End If



Dim fromstr As String

Dim bodystr As String

Dim prioritystr As String

Dim subjectstr As String

Dim startdate As String

Dim enddate As String



Dim doc As NotesDocument

Set doc=Session.DocumentContext





fromstr=doc.MailFrom(0)

prioritystr=doc.Urgency(0)

subjectstr=doc.Subject(0)

startdate=doc.Date(0)

enddate=doc.EDate(0)



Dim dc As NotesDocumentCollection





Dim searchstring As String



searchstring = |Form = "Tasks" & Subject="| & subjectstr & |" & MailFrom="| & fromstr & |" & Urgency="| & prioritystr & |"|







Set dc = db.FTSearch(searchstring, 0)

Dim c As Integer

c=dc.Count

Print c

Subject: RE: DB Search using Lotusscript

Tony

As you’re doing an FTSearch, not a standard Search, your syntax is wrong. Check out the FTSearch help, but basically you need to specify what From, Subject etc. are.

Your syntax should end up looking like:

FIELD From = “Tasks” & FIELD Subject = “Test”

hth

Dan

Subject: RE: DB Search using Lotusscript

No I didnt help either. Any other ideas???Thanks,

Ki

Subject: RE: DB Search using Lotusscript

You need to put the FIELD in front of the field names. Mine looks like this:searchstr = |field Form = “Report” and field ReportTitle = “View Log”|

Subject: RE: DB Search using Lotusscript

What’s the exact error message this time?

Subject: RE: DB Search using Lotusscript

Try this.searchstring= “(FIELD FORM=Tasks & Field Subject Contains " & subjectstr & " & Field Urgency Contains " & prioritystr & " & Field MailFrom Contains " & fromstr & " & FIELD ReceivedOn >= " & startdate & " & FIELD ReceivedOn <= " & enddate &”)"

Rizwan