Update fields on other form?

Hi, I would like to know how can I do it when the user SAVE the docment in formA, I want to update some values in formB based on the a key field.

Here is the details:

FormA have field called project#, value, description.

FormB have the same fields called project#, value, description and other fields.

Once FormA is created, the FormB is unchangable that I did already.

Now when someone change the info. on FormA, I want those three fields get updated on FormB as well if the same project# is found on FormB documents.

I think it can’t do in using formula, could someone give me some direction how to do in script?

Thanks a lot!

Subject: Update fields on other form ?

If there is only going to be one FormB document for every FormA document then you could store the document unique id of the FormB document in FormA. You could then use @SetDocField to set the values in FormB when they change.

Alternatively you could use script in the onSubmit or QuerySave events of FormA using the notesdatabase search method or the notesview FTSearch method. Code below which I have not tested is a rough guide.

Dim ws as new notesuiworkspace

Dim uidoc as notesuidocument

Dim session as new notessession

Dim db as notesdatabase

Dim dc as notesdocumentcollection

Dim doc as notesdocument

Dim doc2 as notesdocument

Set db = session.currentdatabase

Set uidoc = ws.currentdocument

Set doc = uidoc.document

Set dc = db.Search({Form = “FormB” & project = “} & doc.project(0) & {”}, nothing, 0)

if dc.Count = 0 then

exit sub

end if

Set doc2 = dc.GetFirstDocument

while not doc2 is nothing

doc2.project = doc.project(0)

doc2.value = doc.value(0)

doc2.description = doc.description(0)

Call doc2.Save(True, False)

Set doc2 = dc.GetNextDocument(doc2)

wend

if the project field on FormA can be changed then you will need to capture that value in the PostOpen event and amend the Search criteria to search for this value and not the value that is in the field when you save the document.