Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing Computed fields

Status
Not open for further replies.

jdline

Programmer
Dec 10, 2002
3
0
0
US
I have an application that creates documents using a lotus script agent. The script reads an input file and populates most of the fields on the form, the remaining fields on the form are computed fields based on the fields popluated by the script.

I would like to be able to reresh the document so that the computed fields get populated either at the time the form is orginally created or on some schedule later.

I have tried using the following commands in an agent.
@Command([EditSelectAll]);
@Command([ToolsRefreshSelectedDocs]);
@Command([EditDeselectAll]);SELECT @All
This works well when I run it from a view, but I get the following when I try to schedule this agent.

Started running agent 'Scheduled Refresh' on 10/15/2003 11:31:04 AM
Running on all documents in database: 1354 total
Found 1258 document(s) that match search criteria
Started running agent 'DOCREFRSH' on 10/15/2003 11:31:06 AM
Formula error: @Command and other UI functions are not allowed with this search type; please select 'Run once (@Commands may be used)'
0 document(s) were modified by formula
Done running agent 'DOCREFRSH' on 10/15/2003 11:31:06 AM
Done running agent 'Scheduled Refresh' on 10/15/2003 11:31:12 AM


Any help would be great.

Thanks
 
What's happening is somewhere in your agent you are referring to the UIdocument or some other UI interface method and agents can't use the UI functions & methods. You'll need to find where you've referenced them in your script and figure out a way to do it to the doc rather than the uidoc.

HTH

Leslie
 
If I understand correctly, you wrote an agent with formulas that uses the open view, selects all docs and refreshes them.
Then, you just changed the execution parameters from manual to scheduled.
Unfortunately, a scheduled agent that is written with @commands MUST be set to "Run once" (as is mentioned in the error message).
Which means that your view will no longer be selected, which also means that your agent will not work. Why ? Because a scheduled agent is run by the server, and the server does not "open" views, it just accesses the collection of documents defined by the view.

What you need to do is write LScript code. Set the agent to run scheduled on all documents in the database (does not matter for LScript agents). Then use a code like this :

Code:
dim session as new notessession
dim db as notesdatabase
dim view as notesview
dim doc as notesdocument
dim olddoc as notesdocument

set db = session.currentdatabase
set view = db.getview("")'put the name of the view here
set doc = view.getfirstdocument
do while not doc is nothing
    call doc.computewithform(false,false)
    call doc.save
    set olddoc = doc
    set doc = view.getnextdocument(olddoc)
    delete olddoc
loop

That should do the trick.

Pascal.
 
Thanks for the help.

I ended up using the computewithform in my first agent that creates the documents. So that way I only have one agent to run instead of 2.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top