What is the best way to write this in Lotuscript?

I need to be able to look up a group within the server’s names.nsf and grab its list of members. THEN, I need to add those members to an already calculated list, keeping the names unique.

TCMembers := @DbLookup(“”:“NoCache”;@ServerName:“names.nsf”;“Groups”;“Group_TC”;“Members”;[FailSilent]);

tmpAllMembers := @Trim(@Unique(tmpAllMembers : TCMembers));

I need to do this upon Exiting a field which means the code has to be in Lotuscript. Can anyone do the translation? Thanks!

Subject: more info

what’s the name of the field you are in where you want this existing event to fire?

what field on the document is the already calculated list of names in?

What field on the document do you want your result list placed into?

Subject: All 3 the same

what’s the name of the field you are in where you want this existing event to fire?

Upon exiting the field MyList

what field on the document is the already calculated list of names in?

MyList

What field on the document do you want your result list placed into?

MyList

In other words, if the user didn’t add certain names to this field, I want to pull them out of names.nsf and append them to what the user entered thus forcing those names into it.

Subject: this works for me

Sub Exiting(Source As Field)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document

field_list = doc.MyList

group_list = Evaluate(|@DbLookup("":"NoCache";"":"names.nsf";"Groups";"Group_TC";"Members";[FailSilent])|)

new_list = Arrayunique(Arrayappend(field_list, group_list))

Call doc.ReplaceItemValue("MyList", new_list)

Call doc.Save(True, False)

Call uidoc.Reload

End Sub

Subject: One more question

OMG! THANK YOU!!!

One more question, though.

The members of the group_list are returned from names.nsf with their Canonical names. Is there an easy way to get those into their common names (no CN=)? For example, instead of CN=Reuben Smith/OU=Ottawa/O=Acme/C=CA, I want Reuben Smith.

Subject: is it a names field?

If it’s a names field you can put this in the field’s InputTranslation event:

@Name([CN]; MyList)

Also, in the exiting event change uidoc.Reload to uidoc.Refresh

Subject: here it is

You have no idea of how much you are helping me out! I haven’t programmed in Notes in 10 years and they want this done ASAP! High profile.

From the code you gave me

group_list = Evaluate(|@DbLookup(“”:“NoCache”; “”:“names.nsf”; “Groups”; “AgendaGroup-TownClrk”; “Members”; [FailSilent])|)

returns an array of names (I’m not sure if they are actually lotus “names” or just strings) but in their full, canonical format. I want to replace each value in group_list with

@Name([CN]; group_list(n))

Thanks!

Subject: Evaluate doesn’t seem to work

Evaluate(|@DbName([CN]; group_list(count))|)or

dim s as string

s = group_list(count)

Evaluate(|@DbName([CN]; s))|)

both give me Type Mismatch error

Subject: wrong function

You want to use @Name, not @DbName, but I’m not saying your approach will work. You may need to loop thru each member of the array and use the CreateName method to convert it to a true name then extract the common name property then add it to a new array existing of only common names.

Subject: Sorry! typo - I am actually using @Name([CN]; s)

Subject: use this instead, easy

Just wrap the @Name function around your DbLookup

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document

field_list = doc.MyList

group_list = Evaluate(|@Name([CN]; @DbLookup("":"NoCache";"":"names.nsf";"Groups";"Group_TC";"Members";[FailSilent]))|)

new_list = Arrayunique(Arrayappend(field_list, group_list))

Call doc.ReplaceItemValue("MyList", new_list)

Call doc.Save(True, False)

Call uidoc.Refresh

Subject: MY BAD! I didn’t look closely enough

I am getting so frustrated with myself that I didn’t catch the @Name added to the Evaluate.

IT WORKS!!!

THANK YOU!!!

You have no idea of how helpful you’ve been!

Subject: that doesn’t resolve the name issue though :frowning:

The problem is, the names (strings)in group_list are in canonical format and I need them in common format.

group_list contains CN=John Doe/…, CN=Bob Smith/…

I need MyList to contain “John Doe”, “Bob Smith”, etc.