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?
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.
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.
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.