LS - Setting field values in document collection - Help needed

Hi Everyone,

I have a form which has a “Retired” button. When a user selects this button I am wanting the status of that document to be set to “Retired”, but also at the same time I’m wanting it to check a view for any documents which have the same RegMark (Registration) as the current document and to set that/those status to Retired as well.

The only other thing I need to take into account is a field called RegMark_1. RegMark or RegMark_1 will have a value on this particular document where the Reject button is. But… on the other documents, held in the view, the field will only be called RegMark.

Can anyone help? I think I’ve gone down the wrong road, by using GetDocumentByKey ? I’m not sure.

Thanks in advance

Hayley.

Here is the code:

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim ws As New NotesUIWorkspace

Dim doc As NotesDocument

Dim uidoc As NotesUIDocument

Dim view As NotesView

Dim vehicledoc As NotesDocument

Set db=session.CurrentDatabase

Set uidoc = ws.CurrentDocument

Set doc=uidoc.Document

Set view=db.GetView(".vwRVMCF")



uidoc.EditMode = True



If uidoc.FieldGetText( "RegMark" ) <> "" Then

	Set vehicledoc=view.GetDocumentByKey(doc.RegMark(0),True)

	Call vehicledoc.FieldSetText("Status", "Retired")

Else

	RMark1 = uidoc.FieldGetText("RegMark_1")

	Call uidoc.FieldSetText("RegMark", "RMark1")

	Set vehicledoc=view.GetDocumentByKey(doc.RegMark(0),True)

	Call vehicledoc.FieldSetText("Status", "Retired")

End If



Call uidoc.FieldSetText("Status", "Retired")

Call uidoc.Save

Call uidoc.Close

End Sub

Subject: LS - Setting field values in document collection - Help needed

Hi Hayley

This is a very straightforward process:

  1. first get the document you are in - you dont need to get the uidoc - simple back end object wud also suffice.

  2. then use the Search method of the notesdatabase class to get a doc collection of only those docs which have RegMark field set to the value of the current doc e.g.

set docColl = db.Search(“Regmark=” & docThis.RegMark(0), Nothing, 0)

where docThis is your current backend doc object and docColl is a doc collection obj.

then update both the RegMark and RegMark_1 fields in the current doc to the value you want.

e.g.

docThis.RegMark = “x”

docThis.RegMark_1 = “x”

docThis.Save True, True

and then to update the RegMark field in all the documents in the collection use the StampAll method of the document collection class.

You may want to lookup the Designer Help for more complete references to the methods above.

HTH

Arshad