LotusScript Question

Can anyone suggest an easier way for me to compare fields in two different documents than the code I am using. My problem is that I have nearly 300 fields from about 8 different forms, and I need to rewrite the same code 300 times. I would like to do this by using an array if possible, but I am having a hard time understanding the help for arrays in the Domino Designer. Any assistance is greatly appreciated. Here is my code:

	If spooldoc.hasitem("eqp_group") Then

		spooldoc_eqp_group=spooldoc.getitemvalue("eqp_group")

		If thisdoc.hasitem("eqp_group") Then

			thisdoc_eqp_group = thisdoc.getitemvalue("eqp_group")

			If thisdoc_eqp_group(0) <> spooldoc_eqp_group(0) Then

				Call thisdoc.ReplaceItemValue("eqp_group", spooldoc_eqp_group)

				MatchStatus = "Conflict"

			End If

		Else

			If Not Isnull(spooldoc_eqp_group) Then

				Call thisdoc.ReplaceItemValue("eqp_group", spooldoc_eqp_group)

				MatchStatus = "Conflict"

			End If

		End If

	Else

		If thisdoc.hasitem("eqp_group") Then

			Call thisdoc.removeitem("eqp_group")

			MatchStatus = "Conflict"

		End If

	End If

Subject: LotusScript Question

  1. Create a form with one multivalue text field and a button. This button will get the fields for a form you define. The key is to only include the fields you need to compare, which will often times not include hidden fields.

Here is some code that does this type of testing (Downloaded this from the View and customized for my purposes)):

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc=ws.currentdocument

Dim doc As NotesDocument

Set doc=uidoc.document

Dim FieldNames() As String

Dim ParamList() As String

Dim ValueList() As String

Dim FieldCount As Integer

Dim frm As NotesForm

Dim isUserField As Integer

If FormDB Is Nothing Then

If UIDoc.FieldGetText(“DBPath”) = “” Then

Exit Sub

'Get the database

ServerName = doc.ServerName(0)

If ServerName = “” Or ServerName = ""

Then ServerName = “”

Set FormDB = Nothing

On Error Resume Next

Set FormDB = s.GetDatabase(ServerName,

 doc.DBPath(0), False)

If FormDB Is Nothing Or Err <> 0 Then

Messagebox "Unable to open database",

   16, "GetFields"

NewDB

Exit Sub

End If

On Error Goto 0

End If

Set frm = FormDB.GetForm(doc.PickForm(0))

Print “Loading field list…”

Forall fld In frm.Fields

isUserField = True

'Test for $

If Left$(fld, 1) = “$” Then isUserField =

 False

'Test for _

If Left$(fld, 1) = “_” Then isUserField =

 False

'Test for ()

If Left$(fld, 1) = “(” And Right$(fld, 1)

 = ")" Then isUserForm = False

'Test for config

If Instr(Ucase(fld), “CONFIG”) <> 0 Then

isUserForm = False

If isUserField Then

FieldCount = FieldCount + 1		

Redim Preserve FieldNames(0 To FieldCount)

FieldNames(FieldCount) = fld

End If

End Forall

NewForm

'Populate the list of forms

doc.RemoveItem(“PickFieldList”)

doc.PickFieldList = FieldNames

doc.FormSelected = “1”

'Add the form aliases to the field

doc.RemoveItem(“FormAliases”)

doc.FormAliases = frm.Aliases

'Recalc the picklists

UIDoc.Refresh

UIDoc.GotoField(“PickFields”)

Print “Field list loaded”

End Sub

  1. Have your script/agent loop through each of these fields and passs it to a function that does what your original code is doing.

Subject: RE: LotusScript Question

Thanks for the code. I knew there had to be a better way. In my case this is an agent that runs nightly on the server. It compares field values in two forms from different dbs. If they match, nothing happens, if they don’t match, the value in ‘thisdoc’ will always be updated with the value in ‘spooldoc’. If the ‘spooldoc’ field does not exist, then the field in ‘thisdoc’ will be removed. Using the code you have provided, how do I get the field values?