LS not working ...help

Hi all,I have a error handling code that I have copied from this forum to help me debug my LS online and it is reporting something that I don’t understand. The code seems to work correctly (change of status and background emailing) except for the error message that gets printed on the page (as follows). The system is obviously picking up an error but I don’t know what it is and want avoid this error msg when the users will start using this. Can anyone help me figure out what the issue is?

Thanks,

Dan

'==================================================

OOPS …

An error has occured in the application.

Please report the following message to the system administrator:

Code - 0: . (on line 0.)

Click here to return: RETURN

'==================================================

Agent code lanched from the WebQuerySave event of form (@Command([ToolsRunMacro]; “(SubmitWhseDelivery)”)):

Option Public

Use “ErrorHandlingSL”

Dim topicview As String

Dim note As notesdocument

Dim db As notesdatabase

Dim maildb As notesdatabase

Dim favorites As String

Dim currentUser, currentUserEMail As String

Dim categoryview As String

Dim archivingview As String

Dim authorview As String

Dim originalnote As notesdocument

Dim Delivered As String

Dim DeliveryDate As String

Dim WONum As String

Dim Division As String

Dim JobNum As String

Dim DocAuthor As String

Dim st As String

Dim MailSubject As String

Dim MailTag As String

Dim MailTag2 As String

Dim OriginalUNID As String

Dim SendList As String

Dim WOSendList(1) As String

Dim SendListAll As Variant

Dim s As notessession

Dim SendListTrack() As Variant

Dim SendListTrackd() As Variant

Dim ShippingAgent As String

Dim AlertType As String

Dim partialflag As String

Dim Path As String

Dim activitylog

Dim activitytag As String

Dim debugCode As Integer

Sub Initialize

On Error Goto GenErr	



Set maildb = New Notesdatabase("","MAIL1.BOX")

Set s = New NotesSession

Set db = s.CurrentDatabase

Set note = s.documentcontext

path=db.filepath

'-- set to 1 to debug via msgbox at server console

debugCode=0

'-- Get Doc fields

OriginalUNID = note.DocUnid(0)

SendListAll="admin@corp.com"

WONum=note.WONumber(0)	

Division=note.Division(0)

JobNum=note.GPJobNumber(0)

Delivered = note.Delivered(0)

DeliveryDate=note.DeliveredDate(0)

docAuthor=note.Author(0)

currentUserEMail=note.AuthorEMail(0)

partialflag=""



'-- Generate PO Number

If note.WONumber(0)="-Not Assigned-" Or note.WONumber(0)="" Then Call SetWONum(db,note)



'-- Build logic for e-mail

WONum=note.WONumber(0)	

st=note.Status(0)



'== CHECK STATUS

If debugCode=1 Then Msgbox st

Select Case st

Case "Draft"

	Exit Sub	

'-- look if WO has been set to *Submitted* and set flags/email --

Case "Submitted"

'=====================

	note.DateSubmitted=Now		

'-- Generate WO Number

	If note.WONumber(0)="-Not Assigned-" Or note.WONumber(0)="" Then Call SetWONum(db,note)

	activitytag=" Warehouse Order Submitted"

	Call UpdateActivity(activitytag)

	MailSubject= "The following document was " & st & ": WO#" & note.WONumber(0) 

	MailTag="This WO has just been submitted. " 

	MailTag2="Please follow link to view submitted Warehouse Order :"

	AlertType="Initial"

	Call SendMail_WOGroup(AlertType)

	Call SendMail_Issuer(AlertType)

	'Exit Sub  ' if status=submitted then no need to go further

	'-- look if WO has been set to *Cancelled* and set flags/email --

Case "Cancelled"

	note.DateCancelled=Now	

	activitytag=" Cancelled WO"

	Call UpdateActivity(activitytag)

	MailSubject= "The following document was " & st & ": WO#" & note.WONumber(0) 

	MailTag="This WO has been cancelled for the following reasons:" & note.RejectReasons(0) 

	MailTag2="Please follow link to view WO:"

	AlertType="Initial"

	Call SendMail_WOGroup(AlertType)

	Call SendMail_Issuer(AlertType)

	'-- look if WO has been set to *Closed/Delivered to Customer* and set flags/email --

Case "Closed/Delivered to Customer"

	activitytag=" Delivery Date established - Warehouse Delivery Order closed"

	Call UpdateActivity(activitytag)

	MailSubject= "The following document was " & st & ": WO#" & note.WONumber(0)  

	MailTag="This WO has been delivered and closed.:"

	MailTag2="Please follow link to view WO:"

	AlertType="Delivered/Closed"

	Call SendOrderClosedMail(AlertType)

End Select

	'==================================================

	'-- Do the e-mail for order confirmation & arrived at warehouse

If partialflag <>"1" Then Call logStatus



'-- get path (local is for debug)

If db.Server="" Then

	p=note.ThisDBW(0)

Else

	p=Path

End If

GenErr :

Print "<BR><BR>OOPS ... <BR>"

Call PrintErrorMsg( "Code - " & Str(Err) & ": " & Error$ + ".  (on line " & Str(Erl) & ".) ", True)

Exit Sub

End Sub

‘=====================================================

Sub SetWONum(db As notesdatabase,note As notesdocument)

'==Do initial check for new docs only

If debugCode=1 Then Msgbox "Set Delivery WO Number"

Dim vcoll As NotesViewEntryCollection

Dim entry As notesviewentry	

Dim view As notesview

Set view=db.GetView("vLookupDelWODoc")

sstring="WO"



'==Get all entries for that company shortcode in view

Set vcoll=view.GetAllEntriesByKey(sstring,True)



'== Count entries and set default if none found

numdocs=vcoll.count

If numdocs=0 Then 

	msg="Generating Initial Warehouse Delivery WO Number ..."		

	Print msg

	If debugCode=1 Then Msgbox msg

	nextnumber="1000" '1000 is number of 1st WO

	Goto GenerateReturn

End If



'==otherwise get last entry and add 1 onto number

Set entry = vcoll.GetLastEntry()

Set edoc=entry.document

WONum=edoc.WONumber(0)

WONumber=Right(WONum,Len(WONum)-2)

intWONumber=Cint(WONumber)

nextWONumber=intWONumber+1

'==Get length and pad with zeroes (4 digits max)

numlen=Len(Cstr(nextWONumber))

Select Case numlen

Case 1

	prefix="000"

Case 2

	prefix="00"

Case 3

	prefix="0"

Case Else

	prefix=""

End Select

nextnumber=prefix & Cstr(nextWONumber)

GenerateReturn:

'==string shortcode and new padded number together & write to doc

returncode=sstring & nextnumber

note.WONumber=returncode

Dim wodoc As NotesDocument 



'-- Write WO Placeholder by using the "frmDelWONumber" form

Set wodoc=db.CreateDocument

wodoc.form="frmDelWONumber"

wodoc.WONumber=returncode

Call wodoc.Save(True,True)

’ Display message & “Done.”

alertmsg="The following number has been allocated to this Warehouse Delivery WO: " & returncode

Print "<script>alert(" & "'" & alertmsg &"'" & ")</script>"	

Print "<script>location.href='vWhseOrders?OpenView'</script>"

End Sub

‘=====================================================

Sub UpdateActivity(activitytag As String)

If debugCode=1 Then Msgbox "UpdateActivity"

currentUser=Evaluate(|@Name([CN];@UserName)|,note)

activityLog=note.ActivityLog

upperb=Ubound(activityLog)

Redim Preserve activityLog(upperb+1)

For n = (upperb+1) To 1 Step -1

	activityLog(n)=activityLog(n-1)

Next n

activityLog(0)=Format(Now(),"mm/dd/yyyy hh:mm:ss AM/PM") & " (" & currentUser(0) & ") - " & activitytag & "<BR>"

note.ActivityLog=activityLog

End Sub

‘=====================================================

Sub logStatus

If note.CustomerDeliveryDate(0) <> "" Then	

	status="Closed/Delivered to Customer"

	activitytag="Tracking: "  & status

	Call UpdateActivity(activitytag)

Else

	status="Tracking"

	activitytag=status

	Call UpdateActivity(activitytag)

End If

End Sub

‘=====================================================

Sub SendMail_Issuer(AlertType As String)

'-- Create Mailer with http link to notify Issuer that the WO form has been submitted

Dim maildoc As NotesDocument 

Set maildoc=maildb.CreateDocument

'Set maildoc=db.CreateDocument

maildoc.form="Memo"

maildoc.DeliveryPriority="H"

maildoc.subject=MailSubject

maildoc.from="" &"""" & "" & docAuthor & "" & """" & " <" & currentUserEMail & ">"	

Set bodyfield = New NotesRichTextItem(maildoc, "Body")     

Call bodyfield.AddNewLine (2)

Call bodyfield.AppendText("Hello " & docAuthor & ",")

Call bodyfield.AddNewLine (2)

Call bodyfield.AppendText("This is to notify you that your WO has been submitted.")

Call bodyfield.AddNewLine (2)    

Call bodyfield.AppendText(MailTag2)

Call bodyfield.AddNewLine (2)    

Call bodyfield.AddNewLine (1)    

Call bodyfield.AppendText ("http://corpnts1.corp.int/ccs/wo.nsf/fsmain!Open&Frame=fMid&Src=/WONumber/" & OriginalUNID & "!Open&Login")

Call bodyfield.AddNewLine (1)  



'-- Save into the router mail.box

maildoc.Recipients=SendListAll		

Call maildoc.Send(False,SendListAll)

End Sub

‘=====================================================

Sub SendMail_WOGroup(AlertType As String)

'-- Create Mailer with http link to notify WO Group that the WO form has been submitted

Dim maildoc As NotesDocument 

Set maildoc=maildb.CreateDocument

maildoc.form="Memo"

maildoc.DeliveryPriority="H"

maildoc.subject=MailSubject

maildoc.from="" &"""" & "" & docAuthor & "" & """" & " <" & currentUserEMail & ">"	

Set bodyfield = New NotesRichTextItem(maildoc, "Body")     

Call bodyfield.AddNewLine (2)

Call bodyfield.AppendText("Hello,")

Call bodyfield.AddNewLine (2)

Call bodyfield.AddNewLine (2)

Call bodyfield.AppendText(MailTag)

Call bodyfield.AddNewLine (2)    

Call bodyfield.AppendText(MailTag2)

Call bodyfield.AddNewLine (2)    

Call bodyfield.AddNewLine (1)    

Call bodyfield.AppendText ("http://corpnts1.corp.int/ccs/wo.nsf/fsmain!Open&Frame=fMid&Src=/WONumber/" & OriginalUNID & "!Open&Login")

Call bodyfield.AddNewLine (1)  



'-- Save into the router mail.box



maildoc.Recipients=SendListAll		

Call maildoc.Send(False,SendListAll)

End Sub

‘=====================================================

Sub SendOrderClosedMail(AlertType As String)

'-- Create Mailer with http link to notify WO Group that the WO form has been submitted

Dim maildoc As NotesDocument 

Set maildoc=maildb.CreateDocument

maildoc.form="Memo"

maildoc.DeliveryPriority="H"

maildoc.subject=MailSubject



'-- Create Mailer with http link	

'WOSendList(0)="wo@corp.com"

'WOSendList(1)=currentUserEMail

WOSendList(0)="wo@corp.com "

WOSendList(1)="me@corp.com"



maildoc.form="Memo"

maildoc.subject="Notice" & " : WO # " & WONum & " Closed "

Set bodyfield = New NotesRichTextItem(maildoc, "Body")     

Call bodyfield.AddNewLine (2)

Call bodyfield.AppendText(MailTag)

Call bodyfield.AddNewLine (2)    

Call bodyfield.AppendText(MailTag2)

Call bodyfield.AddNewLine (2)    

Call bodyfield.AddNewLine (1)    

Call bodyfield.AppendText ("http://corpnts1.corp.int/ccs/wo.nsf/fsmain!Open&Frame=fMid&Src=/WONumber/" & OriginalUNID & "!Open&Login")

Call bodyfield.AddNewLine (1)  



'-- Send to WO Handlers

Call maildoc.Send(False,WOSendList)

End Sub

‘=====================================================

Script Library (ErrorHandlingSL) code :

Function PrintErrorMsg(errMsg As String, fatal As Integer)

Print {

An error has occured in the application.

Please report the following message to the system administrator:

} & errMsg & {

Click here to return:

Return

}

If fatal Then End

End Function

Subject: LS not working …help

There is no error but your code continues on into your errortrapping.

Just put exit sub above your error trapping like so:

Exit Sub

GenErr :

Print “

OOPS …

Call PrintErrorMsg( "Code - " & Str(Err) & ": " & Error$ + ". (on line " & Str(Erl) & ".) ", True)

Exit Sub

End Sub

Subject: RE: LS not working …help

Thank you Marian,that works for me.

Dan