Search code examples
lotus-noteslotusscript

Saving both Document and Response to database only after the Response document is saved


Is it possible to create a NotesDocument with a Response, where only the response-document is shown on creation, and where both are only saved in the database at the moment that the Response-Document is saved?

I have a Notes-Application for registering work shifts. At the beginning of each shift, the new shift leader have to fill in a handover form in which details about the handover are stored. The shift-Form is the main Form to which all other Forms (such as Handover, in-shift Events) should be response-documents.

At the start of a new work-shift I would therefore wish to create a new Shift-Document, and a Handover-Document. Since the handover takes place first, and I want my users to be able to cancel going into a new shift before they save the Handover-Document, I would want:

  • to first show the Handover-Document to the user, creating the Shift-Document (Parent) in the background
  • only save both documents to the database when the Handover document is saved

How would I do this in Lotusscript?


Solution

  • You can start by creating the child doc (Handover doc) and then make it a response doc after a parent doc has been created and saved.

    Call childDoc.MakeResponse( parentDoc )
    Call childDoc.Save( True, True )
    

    The parent doc must be saved (i.e. have a document unid) in order to make the child doc a response to the parent doc.