Solved

Max Records on Scheduled Agent

Posted on 2009-04-09
45
698 Views
Last Modified: 2013-12-18
Have a scheduled agent that I have been having some issues with. This is one that sends out letters overnight. This database has office records, about 300 and that is the one that these are referencing. In the database there also a large number of user records. The problem appears to be that there are now too many records in the database. The Agent Log shows 7600 total records and the error is "Maximum allowable documents exceeded for a temporary full text index".  Problem here is we use this database each year and half of the user records are from last year and we are hoping to keep the 3000+ user records for historical purposes.

What is the maximum that will work on an agent? And what options do I have here to get this to run? The option on the agent to run on New & Modified Docs just won't work.
0
Comment
Question by:jforget1
  • 16
  • 15
  • 14
45 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24106974
Do you have a Selection formula in the agent? Get rid of it.

You'd better organise your selection differently. Since it's an overnight agent, there's little harm in doing a simple db.Search("Form="ABCD") etc. to get the documents you need.

The alternative is to create a hidden view, and use that in the agent. That seems a waste of resources, for less than 10K records.
0
 

Author Comment

by:jforget1
ID: 24107021
Below is the code from the agent. I do have to selection items on the agent, one if a date is in the next XX days and also that is looking at the office record form. . I have 26 agents that all trigger at various days in advance of them getting all their computers replaced. They are what we call T minus docs that go out in advance. This one goes out 42 days prior to the refresh date.
Sub Initialize
	Dim session As New NotesSession 
	Dim db As NotesDatabase
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim emaildoc As NotesDocument
	Dim Item As NotesItem
	Dim twoliner As String
	Dim rtitem As NotesRichTextItem
	Dim sNamesArr(1)As String
	Dim sNamesArrB(2)As String
	Dim installDate As NotesDateTime
	Dim installDate2 As NotesDateTime
	Dim installTimeItem As NotesItem
	Dim installTimeItem2 As NotesItem	
	Set db = session.CurrentDatabase
	Set col = db.UnprocessedDocuments
	Set doc = col.GetFirstDocument
	On Error Resume Next
	While Not doc Is Nothing
		If doc.ibpc_refresh_1_flag(0)<>"done"  Then
			Set emaildoc = db.CreateDocument
			
			emaildoc.form = "01. ibpc_refresh_t-6" 'Form name of Letter
			sNamesArr(0) = doc.md(0)
			sNamesArr(1) = doc.om(0)
			emaildoc.sendto = sNamesArr
			sNamesArrB(0) = doc.other_email(0)
			sNamesArrB(1) = doc.other_email1(0)
			sNamesArrB(2) = doc.osa(0)
			emaildoc.CopyTo = sNamesArrB
			emaildoc.BlindCopyTo = doc.bcc
			emaildoc.Principal = "Field Technology"
			emaildoc.Subject ="IBPC Refresh for " +  doc.office_num_adjusted(0) + "!" 
			emaildoc.office_num_adjusted = doc.office_num_adjusted
			emaildoc.office_name = doc.office_name
			emaildoc.ussales = doc.ussales
			emaildoc.training_method = doc.training_method
			emaildoc.refresh_type = doc.refresh_type
			emaildoc.ReturnReceipt="1"
			Set installTimeItem = doc.GetFirstItem("install_date")
			Set installTimeItem2 = doc.GetFirstItem("end_date")			
			Set installDate = installTimeItem.DateTimeValue
			Set installDate2 = installTimeItem2.DateTimeValue			
			Call installDate.SetAnyTime
			Call installDate2.SetAnyTime			
			Call emaildoc.ReplaceItemValue("install_date",installDate)	
			Call emaildoc.ReplaceItemValue("end_date",installDate2)				
			Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")			
			Call rtitem.AppendDocLink(doc, "") 
			Call emaildoc.Send(True)
			doc.status = "Announced"
			doc.invite_flag = "done"
			doc.ibpc_refresh_1_flag = "done"    'field name for flag
			Call doc.Save(True,True)
		End If
		Set doc = col.GetNextDocument(doc)
	Wend
End Sub 

Open in new window

0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107196
The easiest would be to select, in the agent's properties, to use all documents in a database (since it's night time agent you needn't worry about performance issues).
Then in the code check whether the current document satisfies your conditions.

E.g. (to simplify the code above):
Sub Initialize
 
%REM
	We use all documents in a db
	Then go one by one and check whether it meets the conditions for sending e-mail
%END REM
	Dim s As New NotesSession
	Dim db As NotesDatabase
	Dim c As NotesDocumentCollection
	Dim cur As NotesDocument
	
	Set db = s.CurrentDatabase
	Set c = db.UnprocessedDocuments
 
	Set cur = c.GetFirstDocument
	Do Until cur Is Nothing
		
		If cur.Form(0) = "Your_Form_Name" Then		'example condition
			Call cur.Send( True )			'this sends the doc along with the form (and assumes you have field SendTo defined in the doc with e-mail recipients)
		End If
		
		Set cur = c.GetNextDocument( cur )
	Loop
 
End Sub

Open in new window

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:jforget1
ID: 24107209
Would I still get the error that there are too many records and then it bombs out?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24107257
No, that's what I suggested, it won't bomb out.

By the way, browsing all documents and skipping the ones you don't need is rather clumsy. Ah, you only want it to run on new or modified documents? That's a different story then.

Otherwise, use db.Search with the formula you had in the agent Selection formula, then walk the document collection that's returned by the method.

By the way... 26 agents??? I always write ONE agent, with 26 subs...
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107310
Why clumsy?
Clumsy is to create a view that's used only by an agent.
This is the easiest and the simplest solution.

db.Search is clumsy and clumsy is to create 26 subs that all does different things in one agent.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107400
Post the code and we'll modify it for you...
0
 

Author Comment

by:jforget1
ID: 24107506
Well let me give you guys a little info to help clear this one up. The reason for all the agents is that letters go out to offices at various points in advance of a particular date. At 6 weeks out a group of offices will get a "Hey your refresh is coming in 6 weeks" the next week those same office will get a "hey 5 weeks till your refresh, here are the next steps". Also the next group of offices will get the letter that they are now 6 weeks out. So it is just a bunch of letters that go out over the course of 6 weeks. I do not think I can to this as one agent as each is based on the number of days they are away from the particular date.

As far as the records, it really only needs to look at the 100 or so office records, these have the date they will be refreshed. The user records also in the DB are not needed for these letters. I can make a view that will only list the current office records, but the agent as it is now will still look to all the documents in the database.

Hopefully I did not make things worse.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107625
Uh, I thought someone else has asked the question initially and you posted one of your agents as an example :)

OK, I think you'll need this one:

Function DateDiff( NewDate As Variant, OldDate As Variant ) As Double
	Dim DateCnt As Long
	Dim NoDays As Long
	Dim BeginDate As Long
	Dim EndDate As Long
	Dim DayOfWeek As Integer
	'
	' This function calculates the difference between two dates in whole days and does not include the start date
	' weekends are also excluded
	'
	On Error Goto errDateDiff
	BeginDate = OldDate
	EndDate = NewDate
	'DateCnt = BeginDate + 1
	DateCnt = BeginDate 
	NoDays = 0
 
	Do While( DateCnt <= EndDate )
		DayOfWeek = Weekday( DateCnt )
		If Not ( DayOfWeek = 1 Or DayOfWeek = 7 ) Then
			NoDays = NoDays + 1
		End If
		DateCnt = DateCnt + 1
	Loop
 
	DateDiff = NoDays
 
exitDateDiff:
	Exit Function
errDateDiff:
	DateDiff = -1
	Resume exitDateDiff
End Function

Open in new window

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24107673
LOL

db.Search clumsy?? No way sir! You select only the documents you need and you dont have to skip thousands of documents. So it will run faster. It will be also a lot clearer what documents the agent will work on. The selection formula inside the agent is easier to read than some code that skips a lot of documents, and certainly if the formula gets complicated.

And we can start another discussion on why it is (not) good to have 26 agents instead of one, where those 26 agents do similar things. But we won't. We will save that for a later time.

0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107725
Maybe you'll need to modify dateDiff function not to exclude weekends, but that's trivial.
I added your piece of code inside If that calculates the date difference (of course that you'll need to add declarations of those vars on top of the code).

I forgot to say, the function dateDiff is from here (so it says in my Code library):
http://www.notes411.com/dominosource/resources.nsf/0/1AF8613E7AEE1465802570550060238B!opendocument
Sub Initialize
 
%REM
        We use all documents in a db
        Then go one by one and check whether it meets the conditions for sending e-mail
%END REM
        Dim s As New NotesSession
        Dim db As NotesDatabase
        Dim c As NotesDocumentCollection
        Dim cur As NotesDocument
        
        Set db = s.CurrentDatabase
        Set c = db.UnprocessedDocuments
 
        Set cur = c.GetFirstDocument
        Do Until cur Is Nothing
                Set oldDate = New NotesDateTime(  )
                
                If DateDiff( Today, oldDate ) <= 42 Then
 
                        'I added your code here:
                        If doc.ibpc_refresh_1_flag(0)<>"done"  Then
                                Set emaildoc = db.CreateDocument
                        
                                emaildoc.form = "01. ibpc_refresh_t-6" 'Form name of Letter
                                sNamesArr(0) = doc.md(0)
                                sNamesArr(1) = doc.om(0)
                                emaildoc.sendto = sNamesArr
                                sNamesArrB(0) = doc.other_email(0)
                                sNamesArrB(1) = doc.other_email1(0)
                                sNamesArrB(2) = doc.osa(0)
                                emaildoc.CopyTo = sNamesArrB
                                emaildoc.BlindCopyTo = doc.bcc
                                emaildoc.Principal = "Field Technology"
                                emaildoc.Subject ="IBPC Refresh for " +  doc.office_num_adjusted(0) + "!" 
                                emaildoc.office_num_adjusted = doc.office_num_adjusted
                                emaildoc.office_name = doc.office_name
                                emaildoc.ussales = doc.ussales
                                emaildoc.training_method = doc.training_method
                                emaildoc.refresh_type = doc.refresh_type
                                emaildoc.ReturnReceipt="1"
                                Set installTimeItem = doc.GetFirstItem("install_date")
                                Set installTimeItem2 = doc.GetFirstItem("end_date")                     
                                Set installDate = installTimeItem.DateTimeValue
                                Set installDate2 = installTimeItem2.DateTimeValue                       
                                Call installDate.SetAnyTime
                                Call installDate2.SetAnyTime                    
                                Call emaildoc.ReplaceItemValue("install_date",installDate)      
                                Call emaildoc.ReplaceItemValue("end_date",installDate2)                         
                                Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")                 
                                Call rtitem.AppendDocLink(doc, "") 
                                Call emaildoc.Send(True)
                                doc.status = "Announced"
                                doc.invite_flag = "done"
                                doc.ibpc_refresh_1_flag = "done"    'field name for flag
                                Call doc.Save(True,True)
                        End If
                End If
                
                Set cur = c.GetNextDocument( cur )
        Loop
 
End Sub

Open in new window

0
 

Author Comment

by:jforget1
ID: 24107782
I am liking the DB.Search method, I think that would involve minimal amount of change. How can I  tweak the existing code Sjef to just search for form name ibpc_refresh_order. There are only a couple hundred of that doc that it would check against. Would I still leave the agent to run on all documents in the database?
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
ID: 24107798
Of course you can do that in one agent! Calculate the number of days until delivery, and handle each document accordingly.
%REM
        We use all documents in a db
        Then go one by one and check whether it meets the conditions for sending e-mail
%END REM
        Dim s As New NotesSession
        Dim db As NotesDatabase
        Dim c As NotesDocumentCollection
        Dim cur As NotesDocument
        
        Set db = s.CurrentDatabase
        Set c = db.Search(|Form="ABCD" & SomeField="xyz" & @Adjust(@Today; 0; 0; 45; 0; 0; 0)=DeliveryDate|)
 
        Set cur = c.GetFirstDocument
        Do Until cur Is Nothing

Open in new window

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24107817
> Would I still leave the agent to run on all documents in the database?
Indeed, not new or modified, and no selection formula.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107818
I always avoid using search or ftsearch from the code.

Why?

db.Search is so slow that my code runs faster then the same code with db.search.
I even tried it a few years back when we had problems with some old code that used Search method, db.search is unreliable and painfully slow!

If the ftsearch is, on the other hand, reliable, but it demands that the db is full text indexed. And even then you get problems like this.


And just for test, try searching manually, from search bar, the database that is not ft indexed. You'll see what the dodgy way of selecting the docs it is...
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107843
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24107887
Look at the Conclusion section, I think it defines the solution to your problem:

FT_MAX_SEARCH_RESULTS=n (where n is the maximum number of documents that can be returned)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24108143
It all depends on the frequency the agent runs and also the number of updates on the database. If it runs
- daily or less: anything will do, even skipping
- twice or more per day: use a db.Search
- hourly: use a hidden view (maybe using GetDocumentByKey)

Only if complex searches are needed, use FTSearch, in all cases. But only then. And even FTSearch isn't perfect, the full-text index has a delay of 5-15 minutes.

> db.Search is so slow that my code runs faster than the same code with db.search.
Can be, but try it on 200 documents, and then 2000, and 2 M... A db.Search gives me EXACTLY what I need. A db.Search is the exact equivalent of building a new view in the database, that's all it does. If you use db.Search once a day, it is less costly compared to updating the hidden view indexes every time a document is updated.

By the way, I never use FTSearch when the database isn't FT-indexed. It just doesn't work.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108223
For db.search the most important thing is number of documents in a database, not frequency. Read the articles I posted the link to (and also: http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/db.search?opendocument&comments#anc1)

I never use it, but if you must, do not ever use it for day time code, especially don't use it for UI operations (operations that can be triggered by an end user).
0
 

Author Comment

by:jforget1
ID: 24108233
Tried rewoking with the search, getting a missing argument for search error. Have I revised the code properly?
Dim doc As NotesDocument
	Dim emaildoc As NotesDocument
	Dim Item As NotesItem
	Dim twoliner As String
	Dim rtitem As NotesRichTextItem
	Set db = session.CurrentDatabase
	'Set col = db.UnprocessedDocuments
	Set col = db.Search(|Form="ibpc_order_form" & doc.ibpc_refresh_1_flag(0)<>"done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)=week_of_install|)
	Set cur = col.GetFirstDocument
	On Error Resume Next
	Do Until cur Is Nothing
		
		Set emaildoc = db.CreateDocument
		
		emaildoc.form = "01. ibpc_refresh_t-6" 'Form name of Letter
		emaildoc.sendto = "Joseph R Forget/Bsg/MetLife/US@MetLife"
		emaildoc.Principal = "Field Technology"
		emaildoc.Subject ="IBPC Refresh for " +  doc.office_num_adjusted(0) + "!" 
		emaildoc.office_num_adjusted = doc.office_num_adjusted
		emaildoc.office_name = doc.office_name
		emaildoc.ussales = doc.ussales
		emaildoc.training_method = doc.training_method
		emaildoc.refresh_type = doc.refresh_type		
		Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")			
		Call rtitem.AppendDocLink(doc, "") 
		Call emaildoc.Send(True)
		doc.status = "Announced"
		doc.invite_flag = "done"
		doc.ibpc_refresh_1_flag = "done"    'field name for flag
		Call doc.Save(True,True)
		Set cur = col.GetNextDocument(doc)
	Loop
End Sub 

Open in new window

0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108264
The syntax is like a formula language, not lotusscript:

e.g.
instead of
doc.ibpc_refresh_1_flag(0)
use
ibpc_refresh_1_flag
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108293
And also:
Set notesDocumentCollection = notesDatabase.Search( formula$, notesDateTime, maxDocs% )

Parameters
formula$
String. A Notes @function formula that defines the selection criteria.
notesDateTime
A cutoff date. The method searches only documents created or modified since the cutoff date. Specify Nothing to indicate no cutoff date.
maxDocs%
Integer. The maximum number of documents you want returned. Specify 0 to receive all matching documents.


So use:
Set col = db.Search(|Form="ibpc_order_form" & doc.ibpc_refresh_1_flag(0)<>"done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)=week_of_install|, Nothing, 0)
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108306
To combine those two suggestions in one  :)

Set col = db.Search(|Form="ibpc_order_form" & ibpc_refresh_1_flag <> "done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)=week_of_install|, Nothing, 0)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24108323
No, not really... Read the f... manual on the Search method..

Set notesDocumentCollection = notesDatabase.Search( formula$, notesDateTime, maxDocs% )

>         Set col = db.Search(|Form="ibpc_order_form" & doc.ibpc_refresh_1_flag(0)<>"done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)=week_of_install|)

That should be coded differently, something like

      Dim query As String
      query= |Form="ibpc_order_form" & ibpc_refresh_1_flag!="done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)=week_of_install|
      Set col= db.Search(query, Nothing, 0)

One question: week_of_install, is that a field in all documents?
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108332
<>
in formula
!=
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108361
Don't be so bitter Sjef.
And read the f... comments before clicking Submit.
0
 

Author Comment

by:jforget1
ID: 24108437
week of install is coded on all docs and converts the actual date that they are installing to the Sunday of that week so we can use it in a view that shows all the installs for that week.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24108519
I'm not bitter at all. I know jforget as a good programmer who usually knows his code, so it amazed me that he didn't look up the correct syntax of the db.Search method. That's all. I wanted to reply with only RTFM, but I considered that to be too blunt. I maybe shouldn't have, sorry jforget...

What comment didn't I read? I was just studying "Lotus Notes/Domino 7 application performance: Part 1: Database properties and document collections" and I can't say I completely agree with the conclusions. They don't take the server's housekeeping into full consideration. But, generally, I agree. What I think is bad is to create the FT-index only for the sake of a midnight agent. But hey, if the server has a 5% utilisation average, who cares... :-P
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108564
Yes you are :P
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24108578
And jForget never looks at the manual :)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24108706
Now you're bitter!
0
 

Author Comment

by:jforget1
ID: 24109154
OK OK I really have started up a little storm on this one. I am not offended, I know that I have lots to learn. One note here, this is not my main job and I have really taught myself most of what I know so there are gabs. For some reason my brain struggles with programming languages in general. But I am trying.
0
 

Author Comment

by:jforget1
ID: 24109189
No errors when saving now, does this look more in line? Also, does the method of doing that date check equate to week_or_install is in the next 42 days?
	Dim doc As NotesDocument
	Dim emaildoc As NotesDocument
	Dim Item As NotesItem
	Dim twoliner As String
	Dim rtitem As NotesRichTextItem
	Set db = session.CurrentDatabase
	'Set col = db.UnprocessedDocuments
	Dim query As String
	query= |Form="ibpc_order_form" & ibpc_refresh_1_flag!="done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)=week_of_install|
	Set col= db.Search(query, Nothing, 0)
	Set cur = col.GetFirstDocument
	On Error Resume Next
	Do Until cur Is Nothing
		
		Set emaildoc = db.CreateDocument
		
		emaildoc.form = "01. ibpc_refresh_t-6" 'Form name of Letter
		emaildoc.sendto = "Joseph R Forget/Bsg/MetLife/US@MetLife"
		emaildoc.Principal = "Field Technology"
		emaildoc.Subject ="IBPC Refresh for " +  doc.office_num_adjusted(0) + "!" 
		emaildoc.office_num_adjusted = doc.office_num_adjusted
		emaildoc.office_name = doc.office_name
		emaildoc.ussales = doc.ussales
		emaildoc.training_method = doc.training_method
		emaildoc.refresh_type = doc.refresh_type		
		Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")			
		Call rtitem.AppendDocLink(doc, "") 
		Call emaildoc.Send(True)
		doc.status = "Announced"
		doc.invite_flag = "done"
		doc.ibpc_refresh_1_flag = "done"    'field name for flag
		Call doc.Save(True,True)
		Set cur = col.GetNextDocument(doc)
	Loop
End Sub 

Open in new window

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24109284
I'll explain:

      @Adjust(@Today; 0; 0; 42; 0; 0; 0)=week_of_install

The @Adjust adds 42 days to the date of today:
      @adjust(somedate; years;months;days;hours;minutes;seconds)

The reulting value is a datetime-value, so week_of_install MUST be a datetime-value too. If you're not certain, check the content of the field in the Document Parameters.

Do you keep some differentiating status in your documents about what has been sent? Ah, ok, the invite_flag... To avoid missing messages, you could change the comparison into
      @Adjust(@Today; 0; 0; 42; 0; 0; 0)>=week_of_install
meaning that if there are 42 days or less left, you send the message.
0
 

Author Comment

by:jforget1
ID: 24109456
OK I have something off here, I did  a test agent that was directed to me. Did a test office record. It kicked out about 40 before I shut off the agent, when I look at the doc properties, I see that the ibpc_refresh_1_flag did not get the done flag so it kept sending the piece. How can I tweak so the flag in triggered. In fact for some reason it still seems to be sending them even after disabling the agent. Finally had to delete the test record in the DB.

doc.ibpc_refresh_1_flag = "done"
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24109743
Use the debugger!!

Hint: Work with either doc or cur...
0
 

Author Comment

by:jforget1
ID: 24109955
Changed the code over to doc. Before I could it thru debugger, although how do you do that for a scheduled agent, it started running and I got close to 100 letters all based on the same office, apparently it was running infinitely on the same record. In looking thru the code, it seems like this should work. I looked at the record that it was running from and the ibpc_refresh_1_flag field had the flag set to done. In fact that was a record from our program last year. This would have already had that flag set to "done".
Sub Initialize
	Dim session As New NotesSession 
	Dim db As NotesDatabase
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim emaildoc As NotesDocument
	Dim Item As NotesItem
	Dim twoliner As String
	Dim rtitem As NotesRichTextItem
	Set db = session.CurrentDatabase
	'Set col = db.UnprocessedDocuments
	Dim query As String
	query= |Form="ibpc_order_form" & ibpc_refresh_1_flag!="done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)>=week_of_install|
	Set col= db.Search(query, Nothing, 0)
	Set doc = col.GetFirstDocument
	On Error Resume Next
	Do Until doc Is Nothing
		
		Set emaildoc = db.CreateDocument
		
		emaildoc.form = "01. ibpc_refresh_t-6" 'Form name of Letter
		emaildoc.sendto = "Joseph R Forget/Bsg/MetLife/US@MetLife"
		emaildoc.Principal = "Field Technology"
		emaildoc.Subject ="IBPC Refresh for " +  doc.office_num_adjusted(0) + "!" 
		Call emaildoc.Send(True)
		doc.status = "Announced"
		doc.invite_flag = "done"
		doc.ibpc_refresh_1_flag = "done"    'field name for flag
		Call doc.Save(True,True)
		Set cur = col.GetNextDocument(doc)
	Loop
End Sub 

Open in new window

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24110021
Oh no, the code is still not correct. You left one cur ... :-)

Don't you use Option Declare or Option Explicit in the Options section??
0
 

Author Comment

by:jforget1
ID: 24110080
I see it now, I normally have the Options Declare in there, I did not notice that was missing. Does my Dim col look right and the Set doc at the end is that now in line?
Sub Initialize
	Dim session As New NotesSession 
	Dim db As NotesDatabase
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim emaildoc As NotesDocument
	Dim Item As NotesItem
	Dim twoliner As String
	Dim rtitem As NotesRichTextItem
	Set db = session.CurrentDatabase
	Dim col As NotesDocumentCollection
	'Set col = db.UnprocessedDocuments
	Dim query As String
	query= |Form="ibpc_order_form" & ibpc_refresh_1_flag!="done" & @Adjust(@Today; 0; 0; 42; 0; 0; 0)>=week_of_install|
	Set col= db.Search(query, Nothing, 0)
	Set doc = col.GetFirstDocument
	On Error Resume Next
	Do Until doc Is Nothing
		
		Set emaildoc = db.CreateDocument
		
		emaildoc.form = "01. ibpc_refresh_t-6" 'Form name of Letter
		emaildoc.sendto = "Joseph R Forget/Bsg/MetLife/US@MetLife"
		emaildoc.Principal = "Field Technology"
		emaildoc.Subject ="IBPC Refresh for " +  doc.office_num_adjusted(0) + "!" 
		Call emaildoc.Send(True)
		doc.status = "Announced"
		doc.invite_flag = "done"
		doc.ibpc_refresh_1_flag = "done"    'field name for flag
		Call doc.Save(True,True)
		Set doc = col.GetNextDocument(doc)
	Loop
End Sub 

Open in new window

0
 

Author Comment

by:jforget1
ID: 24110100
How can I run debugger on this without it kicking out tons of letters if it fails and will doing it manually give me the same result as it running out overnight.
0
 

Author Comment

by:jforget1
ID: 24110248
I think this was the right code work, I ran it thru debugger and got one tracer based on my test record. I ran it thru again and got nothing, as I should have due to the flag being triggered. Now I am just going to do a new test record to see if it works overnight. Although it might run thru as soon as I turn it on.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24112341
Good!! You can debug it manually of course, and there are lots of other ways:
- using a NotesLog object
- using Print statements or MessageBox statements (they put output in the log.nsf database of the server)
- don't send the mail to a real user but to yourself
- don't send the mail to any real user but to Mickey Mouse; the server won't find it and the message will get stuck in the mailbox

If you don't want it to run immediately, then add some code that checks the time. An example:

      If Hour(Now)>5 Then Exit Sub ' don't run after six o'clock

By the way, you could optimize the code, albeit a little. Here's the question you have to ask yourself: why do I create a new maildoc each time?
0
 

Author Closing Comment

by:jforget1
ID: 31568502
Thanks to everyone for the help on this one. Got the tracer just as expected this morning so all is well. I will look to see what I can do to optimize these agents.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24114765
Thanks! You could have let Marko in on this, by splitting the points...

@Marko: I now see what comments I missed, we posted almost identical info simultaneously. Didn't see that, sorry.
0
 

Author Comment

by:jforget1
ID: 24114780
Apologies on that. I was just trying to match up the solution.
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lotus Notes mail can not print out Full page 8 1,305
Lotus notes email code 2 210
Lotus notes VB code 4 209
lotus domino server console error 1 84
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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