0
votes

I am going to boil this down to the basics, because what I have written below is all I have at the moment, and will be able to expand the complexity once I get this working. Please tell me what I am doing wrong.

I inherited a Web application with a main form, with a WebQueryOpen named "WebLoad", and it is written in formula language. It is a very long and complicated formula agent, and I want to have it, on the last line, initiate a LotusScript agent.

The LotusScript is temporarily named "aaa".

This agent is extremely simple:

Dim s as new NotesSession
Dim doc as NotesDocument
set doc = s.documentcontext

doc.aaaTest = "yes"

'this was my last line added to try to get this to work, and it still doesn't.
call doc.save(true,true) 

The last line of the formula agent is : @Command( [ToolsRunMacro] ; "aaa" )

On my main form, I have a computed text field with the formula:

"testfield : " + aaaTest

I would expect, when I open an existing main doc, the computed text to show me:

testfield : yes

but it shows

testfield :

Also, since I am calling the doc.save, I looked at the document properties after I have opened it in a browser, and this field is not even an item on the document.

Either you are unable to call a LotusScript agent from a formula WQO agent, or I am doing something very basic incorrectly.

The LotusScript agent is set to run as a Web user, and has Run on Behalf of set to the Abbreviated name of the User ID with the Manager rights in the ACL.

I confirmed all of the lines in the formula agent run correctly up until this call to run the other agent.

I am hoping someone can see what I have wrong, either in the design or my understanding.

Thank you.

1

1 Answers

1
votes

Your error is: @Commands cannot be used in backend- agents. And every web- agent is executed by the server (http task to be exact) and therefore considered backend- agent.

See this excerpt from the designer help:

You can use @commands in formulas for toolbar buttons, agents that do not specify target documents, events, button hotspots, and action hotspots. You cannot use @commands in a formula that does not interact with the user. These include replication, form, selection, column, hide action, window title, section title, section access, insert subform, hidden paragraph, default value, input translation, input validation, computed value, and keyword field formulas, and agents other than those that specify no target documents.

You need to translate your first agent in LotusScript, then this is not an issue anymore.

OR you need to change the order:

First: Script- Agent with whatever Script in it. And the last lines:

Set ag = db.GetAgent( "BBB" )
Call ag.RunOnServer()

That MIGHT work but I am not sure, if context is transfered to the formula agent...

If that doesn't work you could copy the code from the formula agent in a multiline variable and use Evaluate to run it from LotusScript directly:

Dim strFormulaCode as String
strFormulaCode = |FIELD  x := "y";
FIELD z := "a";
_lkp := @Dblookup( "" : ""; ""; "viw"; "crit; "col" );
....
|
varResult = Evaluate( strFormulaCode, doc )