Problem solve Get help with specific problems with your technologies, process and projects.

Create several response documents after main doc is created

I have a database that is used to track ongoing Projects. It is only a repository that keeps all the documents that pertain to the project itself (i.e. training documents, project plan, QA documents and several other documents that are created from several groups).

When a Project Lead creates the main document (this doc contains the high level info about the project), I want to be able to create several response documents that inherit Project Name and Start and Due Dates when the user saves the main doc. This way the Lead does not have to create all supporting response documents for the other departments.

For example:

Main(Project Info)--- 
   Project Plan--- 
   Training Document --- 
   Meeting Notes --- 
   Other supporting docs 

Do you have any suggestions that can get me going in the right direction?

Use LotusScript in the Postopen event of the Main form. Something like this:

Sub Postopen(Source As Notesuidocument) 
        Const ITEMSTOCOPY = 
{ProjTitle,StartDate,DueDate} ' fill in your fields here 
        Const RESPONSEFORMS =
 {ProjPlan,Training,MeetingNotes,...} ' use form aliases here! 
        Dim db As NotesDatabase 
        Dim docParent As NotesDocument 
        Dim docNew As NotesDocument 
        Dim item As NotesItem 
        Dim forms, itemNames 
        Set docParent = Source.Document 
        Set db = docParent.ParentDatabase 
        forms = Split(RESPONSEFORMS, ",") 
        itemNames = Split(ITEMSTOCOPY, ",") 
        Forall formName In forms 
                Set docNew = db.CreateDocument 
                docNew.Form = formName 
                docNew.MakeResponse docParent 
                Forall itemName In itemNames 
  Set item = docParent.GetFirstItem(itemName) 
                        If Not (item Is Nothing) Then 
Call item.CopyItemToDocument(docNew, itemName) 
                        End If 
                End Forall 
                docNew.Save False, False, True 
        End Forall 
End Sub

However, you are setting yourself up the problem of maintaining the values in these response documents when the corresponding values in the main document changes. If you can combine any of these with the main document you will save yourself some trouble. Either that, or use @GetDocField(@Text($REF); ...) in the response documents to look up the fields you wanted to copy. Maintaining consistent copied data in the response documents is possible but difficult unless you can be sure only one person at a time is editing documents in a particular project.

Do you have comments on this Ask the Expert question and response? Let us know.

Dig Deeper on LotusScript

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...