Hi,
In database, a Scheduled agent run in the server, it changes the values successfully.
But the mail is not by that agent.
In the server log it shows “Error 4000 User defined error”.
However, when I run the scheduled agent by right click on it, sends the mail successfully along with the value changes.
Can anyone please help me? Its little bit urgent.
Subject: Error 4000 User defined error
You will need to post the code for someone to be able to help you with this sort of problem. But before you do you can debug the agent by using the NotesLog class to establish exactly where the error is being raised.
Subject: RE: Error 4000 User defined error
Sub Initialize Dim item As notesitem
Dim session As New notesSession
Dim rtitem As notesrichtextitem
Dim rtitem1 As NotesRichTextItem
Dim doc As notesdocument
Dim doc1 As NotesDocument
Dim maildoc As notesdocument
Dim db As notesdatabase
Dim richStyle As NotesRichTextStyle
Dim flag1 As Integer
Dim view1 As NotesView
Dim count As Integer
Dim var1(2) As Variant
Dim mview As NotesView
Dim mdoc As NotesDocument
Dim docnext As NotesDocument
Set richStyle = session.CreateRichTextStyle
Set db = session.CurrentDatabase
Set maildoc = New notesdocument(db)
Set maildoc1 = New notesdocument(db)
Set view1= db.GetView("S.I.R by Status")
Set doc1 = view1.GetFirstDocument
While Not(doc1 Is Nothing)
Set docnext = view1.GetNextDocument(doc1)
If doc1.Status(0) = "Awaiting Supplier" Then
If doc1.HasItem( "countmail" ) Then
count = Cint(doc1.countmail(0))
Else
count = 1
End If
If count < 5 Then
Set rtitem = New notesRichTextItem(maildoc,"Body")
Call rtitem.AddNewLine(2)
Call rtitem.appendtext("No response has been received to our previous request. Please advise via e-mail address corussuppliesUK@tatasteel.com if any problem are being experienced.")
Call rtitem.AddNewLine(2)
'=====
Call rtitem.appendtext("A Supply-chain Improvement Request reference number " & doc1.NCRNum(0) & " has been raised against your company. Details are shown below.")
Call rtitem.AddNewLine(2)
Call rtitem.AppendStyle(richStyle)
Call rtitem.appendtext("S.I.R Details")
richStyle.bold = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AddNewLine(1)
'Call rtitem.appendtext("The S.I.R Type is " & pldoc3.fieldgettext("NCRType"))
'Call rtitem.AddNewLine(1)
Call rtitem.appendtext("The S.I.R Number is " & doc1.NCRNum(0))
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Date the S.I.R was raised " & doc1.DateRepRaised(0))
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Date the incident took place " & doc1.DateIncident(0))
Call rtitem.AddNewLine(2)
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
Call rtitem.appendtext("Supplier/Contractor Details")
richStyle.underline = False
richStyle.bold = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Supplier Name is " & doc1.SupplierName(0))
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Supplier Address " & doc1.SupplierAddress(0))
'If pldoc3.fieldgettext("NCRType") = "Contractor" Or pldoc3.fieldgettext("NCRType") = "Traffic" Then
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Supplier Code is " & doc1.SupplierCSICode(0))
Call rtitem.AddNewLine(1)
Set ContractorEmailItm = doc1.GetFirstItem( "ContractorQualContactEmail" )
AllSendTo = ContractorEmailItm.Values
TotalIndex = Ubound(AllSendTo)
Redim Recipients(TotalIndex)
k= 0
For index= 0 To Ubound(AllSendTo)
Recipients(k) = AllSendTo(index)
k= k+1
Next
'Call rtitem.appendtext("Supplier Quality Contact Email Address is " & doc1.ContractorQualContactEmail(0))
Call rtitem.appendtext("Supplier Quality Contact Email Address is " & Cstr(ContractorEmailItm.Text))
Call rtitem.AddNewLine(2)
'If pldoc3.fieldgettext("NCRType") <> "Traffic" Or pldoc3.fieldgettext("NCRType") <> "Slab" Then
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
Call rtitem.appendtext("Order/Buyer Details")
richStyle.underline = False
richStyle.bold = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("The order number is " & doc1.OrderNo(0))
'If pldoc3.fieldgettext("NCRType") = "Supplier" Then
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Line Number " & doc1.LinNo(0))
Call rtitem.AddNewLine(1)
’ Call rtitem.appendtext("Advice Note Number " & doc1.AdviceNoteNo(0))
'End If
Call rtitem.AddNewLine(2)
'End If
'If pldoc3.fieldgettext("NCRType") <> "Traffic" Then
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
Call rtitem.appendtext("Item Details")
richStyle.underline = False
richStyle.bold = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("The Item/Service description is " & doc1.ServiceDesc(0))
Call rtitem.AddNewLine(1)
'End If
'If pldoc3.fieldgettext("NCRType") <> "Traffic" And pldoc3.fieldgettext("NCRType") <> "Contractor" Then
Call rtitem.appendtext("Quantity Supplied is " & doc1.QauntitySupplied(0))
Call rtitem.AddNewLine(1)
'End If
'If pldoc3.fieldgettext("NCRType") = "Supplier" Then
Call rtitem.appendtext("Item/Requisition Number is " & doc1.RequisNum(0))
'End If
'If pldoc3.fieldgettext("NCRType") <> "Traffic" Then
Call rtitem.AddNewLine(2)
'End If
'If pldoc3.fieldgettext("NCRType") <> "Traffic" Then
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
Call rtitem.appendtext("Discrepancy Details")
richStyle.underline = False
richStyle.bold = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("The Scope is " & doc1.Scope(0))
Call rtitem.AddNewLine(1)
Set item = doc1.getfirstitem("Scope")
Dim ItemB As NotesRichTextItem
Dim B1 As NotesItem
Dim itemType As Integer
Call rtitem.AddNewLine(2)
'End If
'If pldoc3.fieldgettext("NCRType") <> "Traffic" Then
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
Call rtitem.appendtext("Problem Details")
richStyle.underline = False
richStyle.bold = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Description of Problem " & doc1.NonConDesc(0))
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Is Immediate Action Required? " & doc1.ActionRequired(0))
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("Action Required " & doc1.WhatActionRequired(0))
Call rtitem.AddNewLine(1)
Call rtitem.appendtext("AdditionalInfo " & doc1.AdditionalInfo(0))
Call rtitem.AddNewLine(2)
'End If
'=====
count = count + 1
doc1.countmail = Cstr(count)
Call doc1.Save(True,True)
maildoc.Principal=doc1.From
maildoc.DisplaySent2=doc1.From
maildoc.DisplaySent_1=doc1.From
maildoc.DisplaySent=doc1.From
maildoc.sendto = Recipients
’ maildoc.sendto = doc1.ContractorEmail - removed as this field is now hidden
maildoc.subject = "URGENT - Customer requires response"
Call maildoc.send(False, sendto)
End If
End If
’ Set doc1 = view1.GetNextDocument(doc1)
Set doc1 = docnext
Wend
'maildoc.Remove(True)
End
ErrHandler:
Select Case Err
Case lsErr_NOTES_SEND_FAILED, lsErr_NOTES_NO_MATCH, lsErr_ERR_NOTES_ERROR
Resume Next
Case Else
Print "... Error " & Cstr(Err) & " : ERROR : " & Error(Err)
End
End Select
End Su
Subject: RE: Error 4000 User defined error
Hi,
Please pur error handler inside the agent, try to catch the line no. at which the error is occuring.
Thanks,
RM