PICKLISTCOLLECTION in LotusScript - unique values only?

Hello. Here is some LotusScript code I have written. Is there any way to do a Unique on this view so that the user doesn’t see any duplicate entries? This PickListCollection uses a view that may contain one person’s name dozens of times in that list, but I only want the user to see each person’s name once.

Dim s As New NotesSession

Dim ws As New NotesUIWorkspace

Dim dc_Employee As NotesDocumentCollection

Set db_Current = s.CurrentDatabase

Set dc_Employee = ws.PickListCollection( 3, False, db_Current.server, db_Current.FilePath, _

“V_LK_REGBYEMP”, “Choose employee”, “Choose the employee whose name has changed.”)

Alternatively, I have some code that successfully gets all the names from each document in the database and trims them perfectly - however, how do I prompt the user from a LotusScript agent using these choices? It’s easy to do in a combobox but the agent has no such field choices like a form… anyway here is the code. It returns an array, but how do I give this array to the user and let them choose one string (a name) from the array?

Dim EmpValues As Variant

EmpValues = Evaluate(|@Trim(@Unique(@DbColumn(“”:“NoCache”;“”;“V_LK_REGBYEMP”;1)))|)

EmpOldName = Cstr(EmpValues(0))

If EmpOldName = “” Then

 Messagebox "Cancelling operation: no user chosen."

 Exit Sub

End If

Thanks for reading!

Trish

Subject: PICKLISTCOLLECTION in LotusScript - unique values only?

Trish,

In the view properties, you can turn on “Generate Unique Keys in Index” and it will discard duplicate entries. See if that does the trick.

regards,

raphael

Subject: PICKLISTCOLLECTION in LotusScript - unique values only?

Picklistcollection will just display a view, so no way to remove duplicates in that really.

For the second example look at the prompt method which should do what you want.

Alternatively use a combobox with a button to call the agent once the selection has been chosen (if that’s viable). Look up the ParameterdocID parameter of agent.run - you can pass the current document to the agent and use the value selected in the combobox.

Dan

Subject: PICKLISTCOLLECTION in LotusScript - unique values only?

Trish,

In the view properties, you can turn on “Generate Unique Keys in Index” and it will discard duplicate entries. See if that does the trick.

regards,

raphael

Subject: RE: PICKLISTCOLLECTION in LotusScript - unique values only?

I went to the lookup view and turned on “Generate Unique Keys in Index” and this worked perfectly! THANKS!

Trish

Subject: RE: PICKLISTCOLLECTION in LotusScript - unique values only?

I went to the lookup view and turned on “Generate Unique Keys in Index” and this worked perfectly! THANKS!

Trish

Subject: RE: PICKLISTCOLLECTION in LotusScript - unique values only?

I’ve learnt something new as well. Excellent

Subject: RE: PICKLISTCOLLECTION in LotusScript - unique values only?

I’ve learnt something new as well. Excellent

Subject: “Generate unique keys in index” not reliable

To my utter disappointment, this worked perfectly in development but in production, the lookup view wouldn’t even load. When the user tried to use the function, or when I tried to look at the hidden view, the error was “Entry not found in index.” When I turned off “Generate unique keys in index” the view worked, but of course that adversely affected my agent. My boss said that another developer tried to use “Generate unique keys in index” with similar results across servers. He speculates that perhaps it is a server versioning issue.

At any rate, I redid everything so that when the user clicks “Change Employee Name” in the outline, the formula code right there grabs their choice of the old name using a DBLookup with @Unique and @Trim so all the choices only appear once. I then write the name choice to an environment variable and execute the agent, which grabs that name from the environment variable and continues on with the script.

“Generate unique keys in index” is a great concept - I hope it works more reliably in future versions of Notes.

Trish

Subject: RE: “Generate unique keys in index” not reliable

Tricia,

If memory serves, you get that problem if the first document of a type (not the dupe, but the original) is invalid for some reason, such as being a rep/save conflict. See if excluding $Conflict from the selection formula solves that problem.

I’ve used this technique quite a bit for over 5 years in multiple production environments, so I’m confident that it can work well for you.

regards,

raphael

Subject: RE: “Generate unique keys in index” not reliable

Thanks Raphael - I will certainly give it a try! I really appreciate your answer.

Trish

Subject: RE: “Generate unique keys in index” not reliable

Okie dokie, I added this argument to the view selection:

!@IsAvailable($Conflict)

Which excludes any documents that have the $Conflict field available, just in case… everything is working smoothly so far.

Thanks again!

Trish