Agent error in Embedded view

Hi experts,

I have a form with an embedded view.

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

End Sub

Subject: Agent error in Embedded view

Hi,First…

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…

Subject: Does agent work in embedded view?

Subject: RE: Agent error in Embedded view

Is it possible to make the button work from an embedded view?

I have another button called “add resource” which runs an agent and the agent basically adds a resource to the database.

Subject: Agent error in Embedded view

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: RE: Agent error in Embedded view

If I click the action button in the embedded view - I get a “Document has not been saved” error. → which is the original question in my post…

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

End Sub

Subject: RE: Agent error in Embedded view - clarification

Retriving values from the embedded view - i.e. getting a handle on the embedded view is easy but writing data to the embedded view creates problems …

Even if I save the doc and try to run the agent (run from a button in the embedded view), nothing is updated…