ashik1
asked on
User specific Search and display documents in a view
Hi,
I have a database with a view that displays documents by Date (@created). There are thousands of documents in the database.
How can I provide a facility for users so that they are able to search by a specific date and Notes will display all documents created BEFORE the specified date in the View. This will enable the user to view/delete the documents shown? Answer can be in formula and/or script. Examples would be appreciated. Thanks.
I have a database with a view that displays documents by Date (@created). There are thousands of documents in the database.
How can I provide a facility for users so that they are able to search by a specific date and Notes will display all documents created BEFORE the specified date in the View. This will enable the user to view/delete the documents shown? Answer can be in formula and/or script. Examples would be appreciated. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Arun, I'm very nearly there!
Only one problem - after displaying documents in the folder; if the user does another search, the new search result does not overwrite the previous search results which are still visible in the folder.
Dim ws As New NotesUIWorkspace
Dim dc As NotesDocumentCollection
Dim db As NotesDatabase
Dim ss As New NotesSession
Dim doc As NotesDocument
Dim dateTime As New NotesDateTime( "01/01/95" ) ' Some old date - preferably a date before the db was created
Set db = ss.CurrentDatabase
'
Dim txt As Variant
Dim formula As String
'
txt = Inputbox("Records displayed before (enter the cutoff date):")
formula = "Form = ""abstract"" & date < [" & txt &"]"
Messagebox(formula) ' Remove once testing is completed
Set dc = db.Search(formula , dateTime, 0) ' 0 returns all matching documents
If dc.Count = 0 Then
Msgbox "No documents found for selected category"
'Call dc.RemoveAllFromFolder("By UserDate")
Call ws.ViewRefresh
Msgbox "No documents found for selected category"
Else
Print "Found " & dc.count & " documents for specified category"
'Call dc.RemoveAllFromFolder("By UserDate")
'Call ws.ViewRefresh
Call dc.PutAllInFolder("ByUserD ate")
Call ws.ViewRefresh
End If
Only one problem - after displaying documents in the folder; if the user does another search, the new search result does not overwrite the previous search results which are still visible in the folder.
Dim ws As New NotesUIWorkspace
Dim dc As NotesDocumentCollection
Dim db As NotesDatabase
Dim ss As New NotesSession
Dim doc As NotesDocument
Dim dateTime As New NotesDateTime( "01/01/95" ) ' Some old date - preferably a date before the db was created
Set db = ss.CurrentDatabase
'
Dim txt As Variant
Dim formula As String
'
txt = Inputbox("Records displayed before (enter the cutoff date):")
formula = "Form = ""abstract"" & date < [" & txt &"]"
Messagebox(formula) ' Remove once testing is completed
Set dc = db.Search(formula , dateTime, 0) ' 0 returns all matching documents
If dc.Count = 0 Then
Msgbox "No documents found for selected category"
'Call dc.RemoveAllFromFolder("By
Call ws.ViewRefresh
Msgbox "No documents found for selected category"
Else
Print "Found " & dc.count & " documents for specified category"
'Call dc.RemoveAllFromFolder("By
'Call ws.ViewRefresh
Call dc.PutAllInFolder("ByUserD
Call ws.ViewRefresh
End If
Oops !
I forgot to mention that in my code.
This is simple....
Just add the following code before the inputbox statement.
========================== ========
Dim isdoc as NotesDocument
Dim view as notesview
Set view = db.GetView("SpecDate")
Set isdoc = view.GetFirstDocument
If Not isdoc is nothing then
Messagebox "Please use 'clear view' to clear this view and redo the search."
Exit sub
End if
========================== ========
Keep an action button called "clear view"
and have the following code in it.
==================
@Command([EditSelectAll])
@Command([RemoveFromFolder ])
@Command([ViewRefreshField s])
==================
Good Luck !
-Arun
I forgot to mention that in my code.
This is simple....
Just add the following code before the inputbox statement.
==========================
Dim isdoc as NotesDocument
Dim view as notesview
Set view = db.GetView("SpecDate")
Set isdoc = view.GetFirstDocument
If Not isdoc is nothing then
Messagebox "Please use 'clear view' to clear this view and redo the search."
Exit sub
End if
==========================
Keep an action button called "clear view"
and have the following code in it.
==================
@Command([EditSelectAll])
@Command([RemoveFromFolder
@Command([ViewRefreshField
==================
Good Luck !
-Arun
ASKER
thanks for your help, but I still seem to have problems. Below is your script with slight alterations.
* I'm not sure about the NotesDateTime - is the format i entered correct? i wasn;t sure what date to store.
* I also had to declare var formula. is string okay?
* I have a form called "asbtract".
* The folder I've created has the first column as a Date field which is sorted and categorized.
Dim ws As New NotesUIWorkspace
Dim dc As NotesDocumentCollection
Dim db As NotesDatabase
Dim ss As New NotesSession
Dim doc As NotesDocument
Dim dateTime As New NotesDateTime( "01/01/95" )
Set db = ss.CurrentDatabase
Dim formula As String
txt = Inputbox$("Records displayed before (enter the cutoff date:)")
formula = |Form = "abstract" & @Created < txt|
Set dc = db.Search(formula , dateTime, 0) '0 returns all matching documents
If dc.Count = 0 Then
Msgbox "No documents found for selected category"
Else
Print "Found " & dc.count & " documents for specified category"
Call dc.PutAllInFolder("SpecDat
Call ws.ViewRefresh
End If
The problem is, it keeps telling me that "not documents are found.." when I know for a fact that there are.
What format should I enter the date in the input box?