Dynamically change form field value with ls agent

I have a form with a hidden editable text field, textBody, and a computed field, textDisplayBody, that displays the value in the textBody field.

I would like to run a lotuscript agent from a button on a form. The agent grabs some sorting values from several selection fields on the form, it then uses those sorting values in a call to a stored procedure that returns data from a db2 database. I would like to string all the returned data together and write it to the textBody field so that it is displayed to the user.

The button code:

@Command( [RunAgent] ; “agentViewErrors”);

@Command([RefreshWindow])

To give you an idea of my code in the agent:

Set docSubmitFrom = sesNotes.DocumentContext

strLL = docSubmitFrom.strLL(0)

lngCono = docSubmitFrom.numCono(0)

strErrors = RetrieveErrors (strLL, lngCono)

docSubmitFrom.textBody = strErrors


strErrors shows the correct value but I see no value being moved to the text field.

Any ideas? Suggestions?

Subject: dynamically change form field value with ls agent

I suppose thet the @Command([RefreshWindow]) is executed before your agent has done its thing. You could end the agent with closing the current document and open it again with NotesUIWorkspace.EditDocument.

Subject: RE: dynamically change form field value with ls agent

Thanks for the input.

The document isn’t intended to be saved. The intent is to have the user open the document, select some selection and/or sorting options, the user clicks the button to call the agent that grabs those selections, calls the stored procedure and displays the result set. When the user closes the document, it is not saved. SaveOptions = “0”.

Is this doable? Can a lotuscript agent populate an editable field on the form that calls it?

Subject: dynamically change form field value with ls agent - problem resolved

Instead of running a separate agent, I put the code in the button. Using the uidoc, I can dynamically change the text being displayed.