Question : agent will not run scheduled

Hey Experts I need a little help getting this agnet ot work as a schduled agent. I've scheduled it but it seems to fail evey time.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
Sub Initialize
	Dim session As New NotesSession
	Dim jobnumberList As Variant
	Dim db As NotesDatabase
	Dim docA As NotesDocument
	Dim docB As NotesDocument
	Dim DeleteMe As String
	Dim collection As NotesDocumentCollection
	
	
	Set db = session.CurrentDatabase
	Set collection = db.UnprocessedDocuments
	Set docA = collection.GetFirstDocument()
	
	
	If Instr(docA.ClientName_1(0),"; " ) = 1 Then
	'If Instr(docA.ClientName_1(0), Chr$(13)) < 0 Then
	'If Ubound(docA.CustomerJob) >0 Then
		
	Else
		
		
		If Not (docA Is Nothing) Then
			jobnumberList = docA.GetItemValue("jobnumber")
			Forall x In jobnumberlist
				Set docB = New NotesDocument( db )
				Call docA.CopyAllItems( docB, True )
				docB.jobnumber = Instr(docA.jobnumber(0),";" ) = 1
				docB.jobnumber = x	
				docB.clientname =""
				docB.clientname_1 =""
				docB.customer = ""
				Call docB.ComputeWithForm(True, True)
				Call docB.Save( True, True )
				
			End Forall
		End If
	End If
	
	If Instr(docA.ClientName_1(0),"; " ) = 0 Then
	'If Instr(docA.ClientName_1(0), Chr$(13))>0 Then	
	'If Ubound(docA.CustomerJob) < 1 Then	
		docA.Remove(True)
	End If
End Sub

Answer : agent will not run scheduled

I'd never update a document just to make it fit my needs. You have got to go with the documents and fields you get. So, indeed, code around it, or make sure that your code is foolproof.

For instance, if
      Dim strVal As String
      strVal= doc.SomeField(0)
the contents of strVal will be the empty string if the field SomeField doesn't exist in the document.
If you had defined strVal as Variant, however, the story will be different. (How different exactly I don't know...)

Maybe the easiest thing is to add some error-catching code, using

On Error Goto oops
      ..
      ..
bailout:
      Exit Sub
oops:
      Print "Error " Error$ " on line " Erl
      Resume bailout
Random Solutions  
 
programming4us programming4us