Last active
August 5, 2022 14:59
-
-
Save klehmann/310ca7c785e40d99a8b30c4f750858bf to your computer and use it in GitHub Desktop.
createQRPViewPersons1.lss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%REM | |
Sub createQRPViewPersons | |
Description: Comments for Sub | |
%END REM | |
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 qrp As NOTESQUERYRESULTSPROCESSOR | |
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 | |
errHandler: | |
Error Err, "buildqrpview."+ CStr(GetThreadInfo(1)) + "("+CStr(Erl)+"): "+ Chr(10) + Error() | |
End function | |
%REM | |
Function createTimestamp | |
Description: Comments for Function | |
%END REM | |
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) + _ | |
Right("0"+CStr(Second(now)),2) | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment