I have a form called Approver in "Approver" db.
The form has two editable text fields: Office and Group. It also has a dialog list field superior1.
The superior1 dialog list field should show the staff details filtered based on office & group:
if office = TSP & group = HR
from the approver form, then shud filter the staffs based on these fields group" & "office" with the "Staff info" view of another database "TSP_Staff" and show in superior1.
But it is not getting filtered for me. :(
I am new to this tech, so I am confused and have no one to help me in this. This is the script I used:
for the superior1 field:
Sub Entering(Source As Field)
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim uidoc As NotesUIDocument
Dim doc As Notesdocument
Dim work As New NotesUIWorkspace
Dim workspace As New NotesUIWorkspace
Dim sname As String
Dim consr As String
Dim cview As notesview
Set db = s.CurrentDatabase
Set uidoc = work.CurrentDocument
Set uidocs = workspace.currentdocument
Set c开发者_JAVA技巧view = db.getview("(Application)")
'etype = uidoc.FieldGetText("Office")
'ftype = uidoc.FieldGetText("Group")
etype = "TSP"
ftype = "TSP1-G"
If(etype <> "" And ftype <> "") Then
Call filter
End If
Set view = db.getview("(x_search_staff)")
Set doc = view.GetDocumentByKey (uidoc.fieldgettext("Superior1"),True)
If doc Is Nothing Then
Msgbox "There is no previous transaction please select new trasaction.", 16, "Information"
Call uidoc.FieldClear("Superior1")
Call uidoc.gotofield ("Group")
Call uidoc.gotofield ("Office")
continue = False
Exit Sub
End If
Call uidoc.Refresh
End Sub
from the script library ...
Sub filter
Dim s As New notessession
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Dim doc As notesdocument, newdoc As notesdocument, d As notesdocument, dd As notesdocument
Dim doc1 As NotesDocument, newdoc1 As NotesDocument
Dim dc As notesdocumentcollection
Dim bc As notesdocumentcollection
Dim view As notesview, v As notesview
Dim db As notesdatabase
Dim nextdoc As NotesDocument
Dim cview As notesview
Dim cnview As NotesView
Dim get_db As New notesdatabase(gsserver2, gspath2 & "Master\TSP_Staff.nsf")
Set db = s.currentdatabase
Set view = get_db.getview("(Staff Info)")
Set cview = db.getview("(x_search_staff)")
Set cnview = db.getview("(x_superior)")
Set uidoc=w.CurrentDocument
'To delet searched previous datas from form2 ----------------------------------------
Print "Please wait ..."
key = "Approver2"
Set v = db.getview("(x_delete_2)")
Set dc = v.GetAlldocumentsByKey(key,True)
'Set bc = v.GetAlldocumentsByKey(key,True)
'Call bc.RemoveAll(True)
Call dc.RemoveAll(True)
Call cview.Refresh
Call view.Refresh
Call cnview.Refresh
Call v.Refresh
'To start searching process based on Superior1 --------------------------------------
'f1= uidoc.FieldGetText("Office")
f1= uidoc.FieldGetText("Group")
'f1 = "TSP1-G"
Set dc = view.getalldocumentsbykey(f1, True)
'Set bc = view.getalldocumentsbykey(f2, True)
For b =1 To dc.count
Set doc = dc.getnthdocument(b)
Set newdoc = doc.copytodatabase(db)
'For c =1 To bc.count
'Set doc1 = bc.getnthdocument(b)
'Set newdoc1 = doc.copytodatabase(db)
If doc.form(0) = "Approver" Then
'If doc1.form(0) = "Approver" Then
newdoc.form = "Approver2"
'newdoc1.form = "Approver2"
'End If
End If
newdoc.save True, True
' Next
'newdoc.save True, True
'Next
Call w.viewrefresh
Call cview.Refresh
Call v.Refresh
Call cnview.Refresh
Call view.Refresh
Print "Process Completed....."
End Sub
if u got another way for this requirement temme in stepwise wat to do... or else... chk out ma script for errors... hope u help me :( today due date for this task...
I'm not sure how smart it is to filter the documents shown in a view by deleting documents from a database :)
My suggestion is to first post the code properly. This is simply unreadable.
How to display only subset of documents in your dialog list?
Create a hidden field on your form (you'll fill it with values you want displayed in the list using your code). And then, on your dialog list field properties, second tab, set choices option to be "Use formula for choices" and set it to be the hidden field name.
Ask if you need more help...
Your code is very hard to follow, but if I understand your intention and parts of the filter
function (does it even compile?) you could replace all of the code with this @dblookup-based formula in "use formula for choices" section of superior1 properties:
@dblookup("":"ReCache";"ServerName":"foo\Master\TSP_Staff.nsf";"(Staff Info)";Group;NameOfInterestingField);
You might want to add a @sort and/or @unique around it if the view contain duplicate values, and you might want to add the keyword [FAILSILENT] if some groups should result in an empty list.
An even simpler method could be to configure superior1 to use view dialog for choices.
精彩评论