Data from response doc to main doc

Hi,

I have main docs which could have several response docs and there’s some information that I would like to copy from response docs to main docs if these information is changed, for example manager information or end date. So, for example, if end date on response docs is changed, then it should be copied to main doc, how should I do that? If possible, please give me code example…

Thanks in advance,

Johanna

Subject: Data from response doc to main doc

It should be fairly straight forward:

Each response document has a field called $REF that holds the Document UNID to the main document. Simply get that and copy information that You want. This could be done in the PostSave event of the response form.

Dim session As New NotesSession

Dim dbCurrent As NotesDatabase

Dim docMain As NotesDocument

Dim docCurr As NotesDocument

Set dbCurrent = session.CurrentDatabase

Set docCurr = Source.Document

If docCurr.HasItem(“$REF”) Then

Set docMain = dbCurrent.GetDocumentByUNID(docCurr.GetItemValue(“$REF”)(0))

End If

If Not (docCurr Is Nothing) Then

’ Copy info here…

End If

Subject: RE: Data from response doc to main doc

It can also be done in the following way

Instead of checking for the $REF

if (docCurr.isResponse) then

Set docMain = dbCurrent.GetDocumentByUNID(docCurr.ParentDocumentUNID)

End IF

Subject: RE: Data from response doc to main doc

Thank you all for your advice,

Sorry, but I’m so bad with LotusScript…How do I put this field that should be copied onto this script? If field is called for example Date ( same field on main doc and response doc). When Date on response doc is changed and response doc is saved, Date is copied onto main doc…

Subject: RE: Data from response doc to main doc

Is it possible to copy this Date information not only to main doc, but also to all other response docs that are related to main doc?

Subject: RE: Data from response doc to main doc

In the parent document use the property “Respones”

parentDoc.Responses which will return the document collection which contains all the response docs,

and then Use stampAll to set a field value to common one

set docCollection=parentDoc.Responses

Call docCollection.StampAll(“Dateitem”, DateValue)

Subject: RE: Data from response doc to main doc

So, should I add this script to PostSave event of the response form:( this should copy value of field named Date to main doc’s

Date field )

Dim session As New NotesSession

Dim dbCurrent As NotesDatabase

Dim docMain As NotesDocument

Dim docCurr As NotesDocument

if (docCurr.isResponse) then

Set docMain = dbCurrent.GetDocumentByUNID(docCurr.ParentDocumentUNID)

Call doc.replaceitemvalue (“Date”,“Date”)

End IF

And if I want this Date field to be copied from main doc to all other response docs, should I add this script to main doc’s PostSave event:

Dim session As New NotesSession

Dim dbCurrent As NotesDatabase

Dim docMain As NotesDocument

Dim docCurr As NotesDocument

set docCollection=parentDoc.Responses

Call docCollection.StampAll(“Dateitem”, DateValue)

My LotusCript knowledge is so bad, that’s why I would like to have strict instructions :slight_smile:

Thanks again!

Subject: RE: Data from response doc to main doc

That’s fairly close. However I am concerned because what you are trying to do doesn’t make sense.

Are you saying that this ‘date’ field should always be the same on the parent document and all responses, regardless of which one it is changed on?

Subject: RE: Data from response doc to main doc

Hi,

Unfortunately I have not been able to handle this…Yes, that is what I wanted to do, copy date or changed manager information to all other responses.