Nightly Agent Not Working

I have a field in my database that shows how many days a Work Order Request has been open. I tried to create an agent to run nightly that would automatically run “@Command([ToolsRefreshSelectedDocs])” nightly. So I create a new agent, tell it to run nightly at 12:01AM, and to cover all documents in the database that match my Document Selection formula. When I test the agent, it hits all my selected documents and has no issues. When I run the agent (from the Agent menu), I see the following output:

Started running agent ‘Nightly Refresh’ on 05/12/2005 09:41:58 AM

Running on all documents in database: 66 total

Found 33 document(s) that match search criteria

Formula error: @Command and other UI functions are not allowed with this search type; please select ‘None’ as your runtime target.

0 document(s) were modified by formula

Done running agent ‘Nightly Refresh’ on 05/12/2005 09:42:02 AM

I searched these forums and the internet thoroughly for this error, and found the solution was always to select “None” as the runtime target, but the only way to select “None” is to set the trigger to “On Event”. Can someone please exlpain to me what I am missing here? I know there has to be a way to run an agent nightly without getting this error. Any help is very much appreciated!

Chris Ivey

Verizon Data Services

Enterprise Network Support Services

Network Management Tools Group

Temple Terrace, Florida

Subject: Nightly Agent Not Working

Chris,

from the Notes Developer Help…

Executes a Lotus Notes/Domino command. Most of the standard menu commands can be executed using @Command. In addition, a number of specialized commands are available. In a formula, any command invoked using @Command runs in the order you specify in the formula. This means that any changes made by the command, such as inserting text into a field, affect the rest of the formula (see exceptions below).

Syntax

@Command( [ command ] ; parameters )

Usage

This function does not work in column, selection, hide-when, section editor, window title, field, or form formulas, or in agents that run on a server. It’s intended for use in toolbar button, hotspot, and action formulas.

Why are you refreshing the docs in a scheduled agent? Is it for a particular field? Why not write some script to sort out the specific field, or use ComputeWithForm to update the documents??

Mike

Subject: RE: Nightly Agent Not Working

Well, I am attempting to refresh all my documents opened with either “NewWOR” or “NewWORForUser” forms, so that the “days open” will always be accurate. As it stands today, I have to manually refresh each morning so that if a user accesses one of their WORs to find out what the status is, or if management wants to know what progress has been made to a WOR, the “Days open” will be accurate for each WOR. Seems like the ideal situation for a nightly scheduled agent… apparently not. Any thoughts on how to make this work then?

Chris Ivey

Verizon Data Services

Enterprise Network Support Services

Network Management Tools Group

Temple Terrace, Florida

Subject: RE: Nightly Agent Not Working

It is a great place to use a scheduled agent. Just not ToolsRefresh…, which is a UI function.

Your agent should essentially duplicate the field formula for your DaysOpen field and set the value directly:

@If(Form = “NewWOR”:“NewWORForUser”; “”; @Return(“”));

FIELD DaysOpen := (@Today - @Date(@Created))/86400;

@True

Change the field name to match your reality, and run against all documents in database.