As I cannot limit a view to documents created by the current user I thought maybe I could, in the agent, just select the first document created by the current user however I just can’t get it right.
Anyone just have the code snippet available that lets me select/open the first document created by the current user in a view in order to read out field values?
Subject: Document Selection in LS
If this is notes client only you could use the notesuiview.selectdocument method in the postopen of the view, depending on how easy it would be to get the document last edited by the user.
Alternatively, why not use an embedded single category view - you can then limit the view to documents created by the current user
Dan
Subject: RE: Document Selection in LS
It is an agent that is being run and I wanted to read out a field value of “courses” in the users profile doc. However I just noticed I don’t actually need a view for selection. Every user can only create 1 document in the database. So I’m using now the search method:
Dim coll As notesdocumentcollection
Searchformula$ = { @Contains(Author;@UserName) }
Set coll = db.Search(Searchformula$,Nothing,1)
That works fine although I think there is a more efficient way.
Subject: RE: Document Selection in LS
I suspect a view would be more efficent if there are a large number of docs in the database.
Also, your search formula could just be Author = @Username, which might be slightly more efficient than an @contains. Is there only one form in the database? You could add a Form = “FormName” to the search as well.
Another way of doing it would be to store the UNID of the person’s document in their profile document and retrieving that when needed. You can then use a getdocumentbyunid method which is very efficient.
hth
Dan
Subject: RE: Document Selection in LS
After my exams I’ll probably implement your idea to search directly for the author.Thx for that 
Subject: Document Selection in LS
Seems to me that an embedded view with @UserName as show singel Category could be the solution for you.