I managed to get the agent to work in a non-embedded view.
However, when I tried to run the same agent (via a button in the Embedded view) I received a “Document has not been saved” error.
This is my agent
Basically this approves the selected requests in the embedded view.
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Set db = s.CurrentDatabase
Set coll = db.UnprocessedDocuments
Set doc = coll.GetFirstDocument()
While Not(doc Is Nothing)
doc.Approval1 = s.CommonUserName
Call doc.Save(True, False)
Set doc = coll.GetNextDocument(doc)
Wend
Do u run the agent from the view action button of the embedded View? Or is it a form action/hotspot button? Ur agent script will work from view action button only…
Yes… u can run the agent in the embedded view by click of the action button in that view… Only then you can get handle to those selected docs in the embedded view…
Subject: Agent error in Embedded view - clarification
Just one clarification -
I could get the handle on the view. I.e. I can retrieve values from the embedded view in my agent, however, writing/updating values in the embedded view always springs up “doc not saved error”.
Even if I save the document (and the agent runs without errors), nothing gets updated.
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Set db = s.CurrentDatabase
Set coll = db.UnprocessedDocuments
Set doc = coll.GetFirstDocument()
While Not(doc Is Nothing)
doc.ResourceApproval2 = s.CommonUserName
doc.ResourceApproval2_Date = Date$
Call doc.Save(True, False)
Set doc = coll.GetNextDocument(doc)
Wend