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
197 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

20 Experts available now in Live!

Get 1:1 Help Now