Notes Error - Cannot locate field

Why does this line:v$ = source.FieldGetText(Listtag(F))

produce the error above?

This is part of a piece of code that compares the document’s current field values to its previous field values (taken in the OnLoad event of the form), to check whether any changes have been made. (This is recycled code, by the way.)

Forall F In listPrev

v$ = source.FieldGetText(Listtag(F))

	



	If m$ = "" Then

		m$ = session.CommonUserName & " - " & Cstr(Now()) & " = modified "

	Else

		m$ = m$ & ", "

	End If

	If F = "" Then F = {""}

	xxx = v$

	If xxx = "" Then xxx = {""}

'MyTag is used for display in the audit trail of the user friendly field name, instead of the field name itself

	'If Listtag(F) = "SIRStatus1" Then 

	'	MyTag = "Status"

	If  source.FieldGetText("tStatus1") = "Reopened" Then

		If source.FieldGetText("Assigned_To") = "" Then

		Else

				sendflag = True

			End If

		End If



		'If Listtag(F) = "SysName" Then MyTag = "System Name"			

		'If Listtag(F) = "DateReported" Then MyTag = "Date Reported"

		'If Listtag(F) = "SIRSeverity" Then MyTag = "Severity"

		'If Listtag(F) = "SRNNo" Then MyTag = "SRN Found"

		'If Listtag(F) = "SIRPriority" Then MyTag = "Priority"

		'If Listtag(F) = "TestPhase" Then MyTag = "Test Instance"

		'If Listtag(F) = "AssignTo" Then 

		'	MyTag = "Assigned To"

	If source.FieldGetText("Assigned_To") = "" Then

	Else

		sendflag = True

	End If

'End If

		'If Listtag(F) = "SIRResolution" Then MyTag = "Resolution"

		'If Listtag(F) = "SRNResolved" Then MyTag = "SRN Resolved"

		'If Listtag(F) = "DateSolved" Then MyTag = "Date Resolved"

	

	m$ = m$ & Listtag(F) & " from " & F & " TO " & xxx

'End If

	F = V$

End Forall

listPrev was earlier declared as a List of type String. The code in my OnLoad event is this:

Set session = New NotesSession

bDocSend = False

‘Store fields’ previous values, which will be used for tracking changes upon saving.

'listPrev(“System Name”) = source.FieldGetText(“tSys_Name”)

listPrev(“SIR Status”) = source.FieldGetText(“tStatus1”)

listPrev(“Date Reported”) = source.FieldGetText(“DateReported”)

listPrev(“Severity”) = source.FieldGetText(“cboSeverity”)

listPrev(“SRN Found”) = source.FieldGetText(“tSRN_Found”)

listPrev(“Priority”) = source.FieldGetText(“cboPriority”)

listPrev(“Instance”) = source.FieldGetText(“cboInstance”)

listPrev(“Assigned To”) = source.FieldGetText(“Assigned_To”)

listPrev(“Resolution”) = source.FieldGetText(“tResolution”)

listPrev(“SRN Resolved”) = source.fieldgettext(“tSRN_Resolved”)

listPrev(“Date Resolved”) = source.FieldGetText(“dDateSolved”)

Subject: Perhaps because you are not using the Field Name for the List Tag?

listPrev(“SIR Status”) = source.FieldGetText(“tStatus1”)ListTag(F) would be “SIR Status”. No where do you store the field name tStatus1.

Subject: RE: Perhaps because you are not using the Field Name for the List Tag?

You were right, Bill. I could almost have knocked myself over the head when I realized that while debugging my script.Thanks! =)

Subject: Notes Error - Cannot locate field

Sounds like a good time to run it through debug (even if this is a normally a scheduled agent). Alternately, you could add some print statements so that you know what is happening.

Obviously the array elements in ListTag must be names of fields in your document. My first guess is that it is trying to access a fieldname which is not on a specific document (or there is a bad value in ListTag which is not a fieldname). Do you know which document is having the problem? Which value in ListTag? Which line is bombing? Trap the error so you will have enough information to go on (so far you have nothing). Start with this:

On Error Goto SubError

SubError:

Print "Error: " & Error( ) & " " & Err( ) & " " & Erl( )

print "Listtag(F) = " & Listtag(F)

print "unid = " & Source.UniversalID

’ print significant keys to identify the doc

print "date = " & source.FieldGetText( “DateReported” ) & " SRN = " & source.FieldGetText( “SRNNo” )

end ’ terminate the pgm here!

You may find some of your documents do not have the fields you want. Either fix the documents or adapt the code to handle missing fields.