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
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

690 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