We help IT Professionals succeed at work.

Display While running a Manual Agent

pratigan
pratigan asked
on
593 Views
Last Modified: 2013-12-18
Hello,
I have an agent that sends an email to everyone from a view that has a document still in open status over 5 days.  The script is below.  I'd like to add a display in the agnet so that when I initiate it, I can see a progress bar and total.
TY
paul

Option Public

Sub Initialize
      Dim session As notessession
      Dim doc As notesdocument
      Dim curdoc As notesdocument
      Dim db As notesdatabase
      Dim v As NotesView
      Dim rtitem As NotesRichTextItem
      Dim item As NotesItem
      
      Set session = New notessession
      Set db = session.Currentdatabase
      Set doc = New notesdocument (db)
      Set v = db.GetView( "OpenIRs5")
      
      Set curdoc = v.GetFirstDocument
      Do Until curdoc Is Nothing
            Dim tmpArr() As String
            Dim i As Integer
            
            Set item = curdoc.GetFirstItem( "assigned" )   'instead of Forall loop
            item.IsNames= True
            Call doc.CopyItem( item, "SendTo" )
            
      '      doc.sendto=curdoc.assigned
            doc.principal= "eStar Open IR Auto Notification Monitor"
            doc.Subject = "Assigned IR over 5 days old Pending Your Review."
            doc.Remark = "This notification is autogenerated.  Please do not reply to this email."
            Set rtitem = New NotesRichTextItem( doc, "Body" )
            Call rtitem.AppendText( "This is a Daily Notification Process indicating you have an open IR older than 5 days that Requires your attention. " + Chr(13) + "Please Open, Review and Update the IR." + Chr(13) + "A Final Cause and Resolution are Required. " + Chr(13) + "Thank You !" + Chr(13) + "Open IR Document Link  ->  " )
            Call rtitem.AppendDocLink( curdoc, doc.Subject( 0 ) )
            'Call doc.send(False,curdoc.assigned)
            
            Call doc.Send( False )
            
            Set curdoc = v.GetNextDocument( curdoc )
      Loop
End Sub
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
if you can guarantee the agent will be run on a windows platform, you can use code as detailed in http://searchdomino.techtarget.com/tip/Leverage-the-progress-bar-within-Notes
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
If the Print is ok with you, you usually don't need a print of every document. Instead, you could use

      If progress Modulo 100 = 0 Then

or something like that.

Author

Commented:
ok... Print I guess is fine with me.  I just want to be able to see where the progress is cause sometimes theres a wrong email address which causes the progress to stop.  If I had a progress meter I would see where it stopped.  Not a big deal to display the wrong email, but would be nice to see a progress meter.
So going with the print statements I'm going to set a variable and counter
Dim totalcount As variable
Dim counter as numeric
Set count = 0
then inside the loop under the Call doc.Send( False ) I would put
progress = progress +1
Call Print "Processed " + Cstr( progress ) + " of " + Cstr( totalCount ) + " documents."
??

Author

Commented:
I have setup my DIM statements and the SET command is giving me may only be used on class assignments.  (?)  on print getting unexpected print; expected identified (?)
I have this so far:
ption Public

Sub Initialize
      Dim session As notessession
      Dim doc As notesdocument
      Dim curdoc As notesdocument
      Dim db As notesdatabase
      Dim v As NotesView
      Dim rtitem As NotesRichTextItem
      Dim item As NotesItem
      Dim totalcount As variant
      Dim counter As integer
      
      
      Set session = New notessession
      Set db = session.Currentdatabase
      Set doc = New notesdocument (db)
      Set v = db.GetView( "OpenIRs5")
      Set counter = 0
      
      
      Set curdoc = v.GetFirstDocument
      Do Until curdoc Is Nothing
            Dim tmpArr() As String
            Dim i As Integer
            
            Set item = curdoc.GetFirstItem( "assigned" )   'instead of Forall loop
            item.IsNames= True
            Call doc.CopyItem( item, "SendTo" )
            
      '      doc.sendto=curdoc.assigned
            doc.principal= "eStar Open IR Auto Notification Monitor"
            doc.Subject = "Assigned IR over 5 days old Pending Your Review."
            doc.Remark = "This notification is autogenerated.  Please do not reply to this email."
            Set rtitem = New NotesRichTextItem( doc, "Body" )
            Call rtitem.AppendText( "This is a Daily Notification Process indicating you have an open IR older than 5 days that Requires your attention. " + Chr(13) + "Please Open, Review and Update the IR." + Chr(13) + Chr(13) + "A Final Root Cause and Resolution are Required. " + Chr(13) + Chr(13) + "Thank You !" + Chr(13) + Chr(13) + "Open IR Document Link  ->  " )
            Call rtitem.AppendDocLink( curdoc, doc.Subject( 0 ) )
            'Call doc.send(False,curdoc.assigned)
            
            Call doc.Send( False )
            counter = counter +1
            Call Print "Processed " + CStr( counter ) + " of " + CStr( totalCount ) + " documents."
            
            
            Set curdoc = v.GetNextDocument( curdoc )
      Loop
End Sub

Author

Commented:
new statements added are counter, totalcount and print call.

Author

Commented:
ok.. I realized the print needed a qualifier so I added:
 Dim uidoc As NotesUIDocument
  Set uidoc = workspace.CurrentDocument

and then changed the print to:
Call uidoc.Print ("Processed " + CStr( counter ) + " of " + CStr( totalCount ) + " documents.")
            
but i still have the Set counter problem.  Also how do I set the totalcount value ?
Thank You !
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Set is only to be used for objects. Your variable 'counter' is not an object, so a mere 'counter = 0' suffices.
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Totalcount you can get from the total number of entries in the view.
The compiler would warn him for that if he would heed the Domino Developer Best Practices and always have Option Declare or Option Explicit in his code.
Note that setting the property to do this in Domino Designer forgets to set the Option Declare everywhere when needed, like for example in the form part or actions parts of a NotesForm....

Can be annoying to have to updat all those actions...

Another gotcha is that Shared Actions although purporting to lessen maintenance also bring an aditional burden: by their nature the LotusScript inside Shared Actions cannot be compiled with full Option Declare type checking. So that is done later, in runtime. With all the problems that brings with it...
So now I only use Shared Actions for Simple Actions or Formula Language, and LotusScript is delegated to non-Shared Actions, usually containing only a call into a ScriptLibrary. Icode my agents the same way, so I never have to reschedule my Scheduled agents if there is a code upgrade (mostly). What helps there is the use of Option Private in a lib to force you to surface the interface by using the Public keyword where appropiate.  That way you minimize method and object signature changes.  These signature changes are what necessitate resaves of objects dependant on ScriptLibraries. And I avoid the resaves if possible.
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
@Lars: your comment is valid, but what's the relevance in this question? Cross-posting??    ^_^

Author

Commented:
ok... I've added this under the counter = 0 statement;
totalcount = notesViewEntryCollection.Count

Author

Commented:
I believe I realized that I cannot print using UIDOC as I want to be in total view mode not current document mode so I changed the uidoc DIM and print to:
  Dim uiview As NotesUIView
  Set uiview = workspace.Currentview

Call uiview.print

I'm still getting variant does not contain an object
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Er? Print is a command, not a method in this case.

Print 123

It prints one line to the status bar in a front-end activity (not in background agents).

Author

Commented:
Hi Sjef... I get what your saying.
So I shouldn't even need the uiview. in front of the print ?

The object variant message is coming from the Set uiview = workspace.Currentview

I'm thinking I had to be in view mode with the current view.
I also added Dim workspace As New NotesUIWorkspace because the Workspace variant wasn't being set.
still getting the error now on this statement: totalcount = notesViewEntryCollection.Count
and I do not have the notesViewEntryCollection. prefix defined in a DIM statement.  How should this be defined ?
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Note that using this property can be costly in terms of time. If you have other means of arriving at the total, these can be better performing.

Author

Commented:
lol... your right Sjef.... I couldn't remember the syntax.
Thank You !!

damn I'm rusty at this stuff.  Now I get a type mismatch back on the print statement.

      Call uiview.Print ("Processed " + CStr( counter ) + " of " + CStr( totalCount ) + " documents.")
      
Working it !!
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Get rid of that uiview !!

Author

Commented:
oh yea... my bad.  I removed the Call and the uiview. the script is working and in debugger I see the print output.  I do not see the display box showing me the progress though when I run the agent from the view.... maybe I need more douments in the view to see it.  Testing continues..
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
You won't see a progress dialog box this way, ever. The Print text is displayed at the bottom of the Notes client, in the status bar, where you also see "You have new mail".
Also, if you lose the + and substitute &, you can get rid of the Cstr too..

Author

Commented:
Thank You all for your feedback.  Very much appreciated.  It's great having support like you available.<br />Thanks Again !!<br />Paul

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.