Call an formula agent from lotusscript

Halloin my form i have an action button and the click makes the following lotusscript code:

Sub Click(Source As Button)

Dim agent As NotesAgent

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.currentdocument

Dim s As New NotesSession

Dim db As Notesdatabase

Dim doc As Notesdocument

Set db=s.currentdatabase

Set doc = db.CreateDocument

doc.Form = “Berichtsstatus”

doc.Art = “HP”

doc.Nr = uidoc.FieldGettext(“Nr”)

'---------------

Set agent = db.GetAgent(“MyAgent”)

'Messagebox doc.NoteID

Call agent.Run(doc.NoteID)

End Sub

This is the formula agent:

FIELD Anm:=@If(VBNr!=“”;@DbLookup(“”:“”;“”:“”;“Anmerk”;VBNr;4);“”);

SELECT @All

The problem is in the last line of the ‘click’:

Subject: Call an formula agent from lotusscript

Hi Bob,

Firstly, I think you should to make the agent code in Lotus Script. By lotus script you can get the doc passed by parameter.

Before you call the agent, I think you should to save the doc.

In the agent you should use the class NotesView {view.getDocumentByKey(key, flag)} or search command of Notes Database to simulate the @DbLookup.

I hope to have helped you.

Subject: RE: Call an formula agent from lotusscript

Thanks :slight_smile:

Subject: Call an formula agent from lotusscript

You can include Formulas in your script.

Const Macro=“@SetField(”“Anm”“;@If(VbNr!=”“”“;@DbLookUp(”“”“:”“”“;”“”“:”“”“;”“Anmerk”“;VBNr;4);”“”“))”

res$=Evaluate(doc,Macro)