I am trying to create an agent which creates groups based on location field in the NAB and members to the group. How do I do this?
Try this out to start with and expand for your situation:
Dim nsCurrent As New NotesSession Dim ndbNAB As NotesDatabase Dim nvPeople As NotesView Dim ndPerson As NotesDocument Dim ndGroup As NotesDocument Dim nvGroups As NotesView Dim l_sLocation List As String Set ndbNAB = nsCurrent.CurrentDatabase Set nvPeople = ndbNAB.GetView("($Users)") Set ndPerson = nvPeople.GetFirstDocument While Not ndPerson Is Nothing l_sLocation(ndPerson.Location(0)) = l_sLocation & ", " & ndPerson.MailAddress(0) Set ndPerson = nvPeople.GetNextDocument(ndPerson) Wend ForAll L In l_sLocation Set ndGroup = nvGroups.GetFirstDocumentByKey(ListTag(l_sLocation)) If ndGroup Is Nothing Then Set ndGroup = ndbNAB.CreateDocument ndGroup.Form = "Group" ndGroup.Name = ListTag(L)) End If NdGroup.Members = L Call ndGroup.ComputeWithForm(False) Call ndGroup.Save(True, False) End ForAll
Depending on the version of Notes you are running, you might want to double-check and make sure ComputeWithForm works for you in expanding the group members. If it doesn't, then use a little code to explode the contents of "L" and put them in the group using a NotesItem and its method "AppendToTextList".
Dig Deeper on Domino Resources - Part 3
Related Q&A from Todd Fuder
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.