Solved

When I am running the below script it tells me that I can only run it from the view.  I need to run it on a schedule.

Posted on 2004-09-08
7
200 Views
Last Modified: 2013-12-18
What am I doing wrong?  Also can it replace the doument in the view instead of creating a new one each time?

Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim rtitem As NotesRichTextItem
      Dim object As NotesEmbeddedObject
      Dim notestime As New notesdatetime("")
      Dim notesdate As New notesdatetime("")
      notesdate.LocalTime = Date
      notestime.LocalTime = Time
      Set db = session.CurrentDatabase
      Set doc = New NotesDocument( db )
      Set rtitem = New NotesRichTextItem( doc, "Body" )
      Set doc.ProcessDate= notesdate
      Set object = rtitem.EmbedObject _
      ( 1454 , "", "\\xxxx\xxxx\xxxxxx\xxxx.xls")
      doc.Form = "xxxx"
      doc.Subjectproductions = "xx"
      doc.productionrpt = "xxxxxx"
      doc.createddate = notesdate.LocalTime
      doc.createdtime = notestime.LocalTime
      Call doc.Save( True, True )

End sub

Thank
0
Comment
Question by:sjmmajor
7 Comments
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 100 total points
ID: 12007974
You have set the agent to run on selected docs.. change it to schedule more than once a day or daily

~Hemanth
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 400 total points
ID: 12008150
Hi sjmmajor,

The default way agents are create is to "run: Manuall from actions menu" and to "act on: selected documents."  That's not what you want to do.  You want it to "run: on schedule."  The schedule can be monthly, weekly, daily (once per day), or more than once per day (every five minutes, ten minutes, hour, four hours, 7 hours and 15 minutes, etc.).  That's the amount of time Domino will wait BETWEEN each run (from the end of one run to the start of the next).

You shoudl also set it to "act on: all documentsin database."  I know you really are not acting on all the database's documents -- your agent ignores the list of documents that Notes presents.  I only tell you to set this because it makes the agent manager more efficient.

-----

As to replacing the existing doc instead of creating a new one, here's how you do it.  Replace the following line:

     Set doc = New NotesDocument( db )

With:

     CONST viewName = "********** put the name of your view here -- preferably, this shoudl be a view that users do NOT see, so that if they ask for changes to a visible view, it does not affect your agent."
     Dim view as notesView
     Set view = db.getView(viewName)
     Set doc = view.getFIrstDocument
     If doc is Nothing then
         Set doc = New NotesDocument( db )
     Else
        doc.removeItem("Body") 'so the "Set rtItem = New NotesRichTextItem" does not fail; the other fields will be ok whether new doc/old doc, because, e.g., doc.Form = "..." creates OR replaces a value
     End If



Cheers!
0
 

Author Comment

by:sjmmajor
ID: 12008992
qwaletee - the change to the agent for replacing worked well.  GREAT!!  

I changed the agent to schedule and on all documents and right now I have it schedule to run every 10 mins but it isn't running.  I have other scheduled agents that do run and I looked at them but can't see any differences.  

Any other ideas??

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sjmmajor
ID: 12009479
I had to change the restrictions to allow restricted operations for the agent to run on schedule.  So the schedule part is completed and I thank all.  I will split points.

I can open another question if you would like but you know when you use view.getfirstdocument?  Can I select second document or 3rd document?  As I am thinking about it, I am going to be running this for 3 shifts and want to maintain 3 documents.

0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12009568
It would be fair to open a new question for this. I am posting it here just because you haven't posted the new one yet ;-)


Shcedule agents - Shcedule agents do not run on a view. Any attempt to do a getfirstdocument would be fruitless untill you have a view handle. THe method to loop thru the set of the documents eligible for run is to use the UnprocessedDocuments proeprty of the NotesDatabase class. This property returns you a NotesDocumentCollection object. See designer help to learn more on how to use this property.


From the designer help.

Read-only. The documents in a database that the current agent or view action considers to be "unprocessed." The type of agent determines which documents are considered unprocessed.

Example code:

Sub Click(Source As Button)
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim collection As NotesDocumentCollection
  Dim doc As NotesDocument
  Set db = session.CurrentDatabase
  Set collection = db.UnprocessedDocuments
  For i = 1 To collection.Count
    Set doc = collection.GetNthDocument( i )
    Set item = doc.GetFirstItem( "Approver" )
    If item.Contains( session.UserName ) Then
      doc.Approved = "Yes"
      Call doc.Save( False, True )
    End If
  Next
End Sub
0
 

Author Comment

by:sjmmajor
ID: 12009820
I have just posted the question.  Can you put your entry there or is there something I can do?
0
 

Author Comment

by:sjmmajor
ID: 12015503
Thanks to all!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now