Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sub createQRPViewPersons
Description: Comments for Sub
function createQRPViewPersons1(qrpViewReaders As Variant, expirationHours As Integer) As String
On Error GoTo errHandler
Dim session As New NotesSession
Dim db As NotesDatabase
Dim viewName As String
Dim ndtNow As NotesDateTime
Set db = session.currentdatabase
viewName = "qrp_persons1_"+createTimestamp()
Set qrp = db.Createqueryresultsprocessor()
'define data sources:
'pull all person docs from waddress main view:
Dim dbAddress As New NotesDatabase(db.Server, "111dev/waddress.nsf")
Dim dqlAddress As NotesDominoQuery
Dim doccolAddressAllInMailView As NotesDocumentCollection
Set dqlAddress = dbAddress.Createdominoquery()
'use a DQL search to find Person docs
Set doccolAddressAllInMailView = dqlAddress.Execute( _
|form = 'Person'|, _
"address_mainview_persons", True, 24)
'in theory this should also work and provide better performance, but somehow
'the DQL engine does not like the view name (asked John Curtis for help)
'Set doccolAddressAllInMailView = dqlAddress.Execute( _
'|in ('$ViewADAddressByInstitution') and form='Person' |, _
'"address_mainview_persons", True, 24)
qrp.Addcollection doccolAddressAllInMailView, "persons_waddress"
'add persons from wwork.nsf
Dim dbConfig As New NotesDatabase(db.server, "111dev/wwork.nsf")
Dim viewConfigUsers As NotesView
Set viewConfigUsers = dbConfig.getView("$ViewUserByCompany")
Dim allConfigUserEntries As NotesViewEntryCollection
Set allConfigUserEntries = viewConfigUsers.Allentries
qrp.Addcollection allConfigUserEntries, "persons_wconfig"
'add persons from the Domino directory:
Dim dbNAB As New NotesDatabase(db.server, "names.nsf")
Dim viewPeople As NotesView
Set viewPeople = dbNAB.getView("People")
Dim allPeopleEntries As NotesViewEntryCollection
Set allPeopleEntries = viewPeople.Allentries
qrp.Addcollection allPeopleEntries, "persons_nab"
'define view columns:
'programmatic name, title, formula, sorting, ishidden, iscategory
qrp.Addcolumn "lastname", "Lastname", "Lastname", SORT_ASCENDING, False, True
qrp.Addcolumn "lastname", "Lastname", "Lastname", SORT_ASCENDING, False, False
qrp.Addcolumn "firstname", "Firstname", "Firstname", SORT_ASCENDING, False, False
qrp.Addcolumn "dbtype", "DB Type", "", SORT_ASCENDING, False, False
'override dbtype formula for each data source:
qrp.Addformula |"Weilgut Address"|, "dbtype", "persons_waddress"
qrp.Addformula |"Domino NAB"|, "dbtype", "persons_nab"
qrp.Addformula |"Weilgut Config"|, "dbtype", "persons_wconfig"
'and override lastname/firstname formulas for wwork:
qrp.Addformula |ADLastname|, "lastname", "persons_wconfig"
qrp.Addformula |ADFirstname|, "firstname", "persons_wconfig"
qrp.Executetoview viewName, expirationHours, qrpViewReaders
createQRPViewPersons1 = "(" + viewName + ")"
Exit Function
Error Err, "buildqrpview."+ CStr(GetThreadInfo(1)) + "("+CStr(Erl)+"): "+ Chr(10) + Error()
End function
Function createTimestamp
Description: Comments for Function
Function createTimestamp() As String
createTimestamp = Right("0"+CStr(year(now)),2) + _
Right("0"+CStr(Month(now)),2) + _
Right("0"+CStr(Day(now)),2) + _
Right("0"+CStr(Hour(now)),2) + _
Right("0"+CStr(Minute(now)),2) + _
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment