Creating Agents

I created an agent that is suppose to run everyday to check on a field in all my documents.  I want it to change the value of NEW in my status field to OLD if the date today is greater than the date receive field in my form.  No errors appeared but it does not update my status field?
ememAsked:
Who is Participating?
 
madheeswarConnect With a Mentor Commented:
I believe u will increase points and I am giving my code:

place this into an agent.
Note: replace the view name.




Sub Initialize
      Dim ss As New notessession
      Dim db As notesdatabase
      Dim view As notesview
      Dim doc As notesdocument
      
      Set db=ss.currentdatabase
      Set view=db.getview("UrViewname")  'here replace ur view name.
      Set doc=view.getfirstdocument
      
      While Not doc Is Nothing
            doc.stat="Outstanding PDC"
            Call doc.save(True,True)
            Set doc=view.getnextdocument(doc)
      Wend
End Sub
0
 
ememAuthor Commented:
btw here is my formula in the agent I created

SELECT @All;
@If (stat ="New PDC" & @Today>dtercv);stat = "Outstanding PDC";stat
0
 
madheeswarCommented:
use this:

FIELD stat:=stat;
FIELD dtercv:=dtercv;
@If(stat="New PDC" & @Today>dtercv; @SetField("stat";"Outstanding PDC";stat)


or else,
create a view and the selction formula for that view will be

SELECT Form="UrFormName" & (@today>dtercv) & (stat="New PDC)

Now create an agent and Run on all documents in the view and optin is the above view name

And formula is

FIEDL stat:="Outstanding PDC";
""
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ememAuthor Commented:
too many arguements for @function is the 1st formula you gave me
0
 
madheeswarCommented:
change it to
:
FIELD stat:=stat;
FIELD dtercv:=dtercv;
@If(stat="New PDC" & (@Today>dtercv); @SetField("stat";"Outstanding PDC");stat)

0
 
ememAuthor Commented:
i'll test it ....thanks again madheeswar ...you never quit on helping me =)
0
 
qwaleteeCommented:
Or, simpler...

SELECT stat ="New PDC" & @Today>dtercv;
FIELD stat := "Outstanding PDC";

Two lines are better than four :)
0
 
ememAuthor Commented:
how come the agent does not run on the schedule I stated I want it to run every day but it does not work unless that I run it manually how is this so? I cannot view the results
0
 
madheeswarCommented:
Two line is better.

and agent not running, u should be selecting to schedule daily and run on all documents in the view.

tell ur config of agent(selection , when this agent should run, etc.,,)
0
 
ememAuthor Commented:
yah may config is as follows:

Agent Name : Check Status
When should this agent run on Local? On Schedule daily starting 1:00AM
Which documents shoult it act on?
All documents in the database

and I have the formula you gave me ....and it is checked in the agents option....do i need to include anything for it to run?
0
 
madheeswarCommented:
select the agent and from menu. Agent->Log

it should display when it has been run.
Inorder to test it again, change the time 1Am to another time which is convenient for you and test.

Don't touch the agent again untill it finished its schedule.

And u can use Qwaletee Solution which is simple and have the same result.

0
 
ememAuthor Commented:
i'll try this again hope it works i'll change the time
0
 
ememAuthor Commented:
it still did not run ...it only applied the changes when I click on it to run ....
0
 
ememAuthor Commented:
it does not function automatically
0
 
madheeswarCommented:
What is ur Agent log says?

Did it run?

create a view and the selction formula for that view will be

SELECT Form="UrFormName" & (@today>dtercv) & (stat="New PDC)
the above solution should display some documents. Is the documents are there?
0
 
ememAuthor Commented:
the agent has never been runned......ill try to do the view
0
 
madheeswarCommented:
the agent is not running on schedule.  But when the agent runs manually will the fields status changes the value?

I think it is with config of server.
0
 
ememAuthor Commented:
the view now displays the records with dtercv<@today and stat = "New PDC".... I created an agent that will replace the value of stat what shld be the config?
0
 
madheeswarCommented:
in the server configuratoin document in names.nsf on server, ur name should be listed to run restricted Lotus script.

else, sign the application with admin id and schedule it.

did u added ur search?
there is a button in the agent. click on Add search and selct folders from the menu.

and add the view on which it should run.
0
 
ememAuthor Commented:
ill try your suggestion i hope this particular agent would work
0
 
ememAuthor Commented:
madheeswar hello ...is there another solution to run this agent? is it possible that once I open the database a screen or message would prompt the user that the agent needs to be run for updates b4 they proceed with any transaction?
0
 
madheeswarCommented:
Or with the same setup, create a Lotus Script agent.

Please increase the points, as I need to write script for it.
0
 
ememAuthor Commented:
madheeswar will this code run automatically? I will place this code in an agent and run it on a schedule daily.....
0
 
madheeswarCommented:
Is this working or not?
if it is working, then close this quesoitn with grade A and increase points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.