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
207 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to automate deletion of content in Lotus Notes mailboxes 3 223
Lotus notes error message 6 104
Only send email if contains "abcd" 3 148
Lotus Domino server 11 67
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…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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