How to get Agent Note Id in LS?

Hi there,

how can I get the NoteId of an agent in LotusScript ?

Usually all documents have the property NoteId, but the LS Agent object does not contain this property.
Yes I can search for the agent with a NotesNoteCollection, but its pretty slow, especially when its in a db with lots of agents.

Need it to verify the $AssistFlags field to detect whether it runs in the background or foreground.

Kind Regards

Jochen "Joe" Herrmann

Hello.

I think that the only way to get the NoteID of an Agent is to use NotesNoteCollection.
As the NoteID of an Agent does not change, why not treat it as a fixed value?
Alternatively, it might be a good idea to keep the NoteID in a profile document, for example.

Regards,
Shigemitsu Tanaka

Hi Joe,

Hope you are doing good!

Sample Code :
--------------------------------------
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Set db = s.Currentdatabase
Set dc = db.Unprocesseddocuments
Set doc = dc.Getfirstdocument()
MsgBox doc.Noteid
--------------------------------------
OR
Create one simple view and handle that particular document instead of the document collection in the database.
We would request you to refer the following product documentation on NoteID property in the Notes Document class.
Title : NoteID (NotesDocument - LotusScript®)
URL --> https://help.hcl-software.com/dom_designer/14.0.0/basic/H_NOTEID_PROPERTY.html

Note: for your awareness, we have launched a new Digital Solutions Community site (https://developer.ds.hcl-software.com/) which includes our new product forums

The content for our legacy product forums will soon be migrated to this new site. If you haven’t yet done so, we encourage you to sign up on the site and engage with the community of experts for our products!!

Thank you

Just curious. How do you use the noteid once you get that even via notecollection. That can be sped up by setting all other options to false other than agents while building the collection. But in case some field is to be passed to an agent that could be handled via some profile document or via agent parameterdocid if called with a document context.

Im sure you have a better idea using noteid. Dont get me wrong, im Just curious to know that. I would guess you are talking about $Flags.

@Rajneesh Sharma
I use the NoteId to load the agent as a document. Then I have access i.e. to the field "$AssistFlags" which gives me in this case the information whether this agent is used in the backend or foreground.
Kind Regards

Joe

If you really want to, copy the ($Design) view from this db, the view lists design elements like notes document (getdocumentbykey will work, and all methods from notesdocument), if it helps everything is in the $Flags of the view, you can change formula selection of the view etc...

DesignView.nsf.zip

@Jerome Deniau
Yes, thats also a solution that could work well, but I wanted to avoid to create another view ony to get the agent document ....
Kind Regards

Jochen "Joe" Herrmann

@Joe , you can use this view for many purposes, for instance instead of database properties > Design > Template version. You can use this view to display your application version ($TemplateBuild). I do use it in my apps, it is easier for the admins or users to tell me which version they run without using shortcuts, db properties, administrator etc.....

Ok I found a solution without creating a new view:

n$=LCase$(Me.Agent.Name)
Set NNC = me.db.CreateNotecollection(False) 
NNC.Selectagents=True
NNC.Selectionformula={@LowerCase($TITLE) = "} & n$ & {"}      'added this filter 
NNC.Buildcollection

This is a fast method to retrieve the agent doc. The SelectionFormula method did the trick. Its cummulative with SelectAgents.

Kind Regards
Joe

Perfect!