Why? Because Group names change; over time, between your Development, UAT (User Acceptance Testing) and Production enviroments, between diffenet customers.
How? By far the best way to reduce hard coding is with a Global Profile Doc, that is a profile document without a username, to store information for all users of the database. Any and all piece’s of data from outside your application should be placed in a admin profile document, and a great many intianl peices as well, Wheather or not your applications bussiness users adminsrate them or a techinal adminstrator does.
As a demonstration, I’ll improve a previous Show-n-Tell+Thursday entry, Using the Lotus DBlookup to better Leverage the Name and Address book and make it better.
In the Case of reducing the Hard Coding of group names, on your Admin Profile form (call it “profileAdmin”) add a Name field for the PHB approvers group called (what else) “Name_PHB_Approvers_GroupName” which use can populate with a standard “Use Address dialog for choices”.
then rather that using :
1 | key :="Pointy_Hair_Bosses_with_Authority_in_this_Line_of_Business"; |
in your Structured DB lookup, use :
1 | key := @GetProfileField( "profileAdmin"; "Name_PHB_Approvers_GroupName" ); |
to retrieve the value. Remember that you can also retrieve profile document field values in lotusscript as well.
A further feature to add to your profile documents, to make it “one place shopping”, is to make it easier to view or edit the group just selected by making a click-able (button or image ) to open, in read mode, the selected Group Document from the Name and address book (NaB).
I’ve done this by placing a image next to the field, surrounded by a action hotspot which calls a lotus subroutine :
1 | OpenNabGroupforDisplay ("Name_PHB_Approvers_GroupName") |
which calls this lotusScript:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | Sub OpenNabGroupforDisplay (groupFieldName As String) ' pass the name of the field containing the group name, on the currently open document. On Error Goto onError Dim workspace As New NotesUIWorkspace Dim uidoc As NotesUIDocument Dim session As New NotesSession Dim db As NotesDatabase Dim nabDB As NotesDatabase Dim view As NotesView Dim doc As NotesDocument Dim GroupName As String Dim Guidoc As NotesUIDocument if groupFieldName = "" then messagebox "No FieldName supplied, contact your Notes Developer" Exit Sub end if' get the value in the field name Set db = session.CurrentDatabase Set uidoc = workspace.CurrentDocument groupName = uidoc.FieldGetText( groupFieldName ) If groupName = "" Then messagebox "No value for " & groupFieldName & " supplied." Exit Sub End If ' get the group by groupName for this Server in the NaB. Set nabDB = session.GetDatabase( db.Server, "Names.nsf") Set View = nabDB.GetView( "($VIMGroups)" ) Set doc = view.GetDocumentByKey( groupName, True) If doc Is Nothing Then messagebox "Cannot find a group by the name " & groupName & "." Exit Sub' open the group in read mode Set GuiDoc = workspace.EditDocument( False, doc)Exit Sub onError: Messagebox "System Error " & Err() & ": " & Error$ & ", line: " & Erl Exit Sub End Sub |
Question: I have not been able to find the image (.gif) that the Notes client uses when you paste in a Doc Link (Document Link), which would be my preferred image in this case.