Roelof van den Berg
Roelof van den Berg

Reputation: 100

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:

How would I do this in Lotusscript?

Upvotes: 1

Views: 222

Answers (2)

Tom Van Aken
Tom Van Aken

Reputation: 467

You must always save the Parent document first before you can create response documents to it.

However, you can use this workaround.

Create a dummy form 'Shift with Handover' where the shift leader can enter the data for both the Shift document and the Handover document.
Then, in the QuerySave of this form:

  • create the Shift document with all the necessary fields (don't forget to set the form field to Shift) and save it.
  • create the Handover document with all the necessary fields (don't forget the form field) , make it a response to the shift document and save it
  • finally, in the QuerySave of the 'Shift with Handover' document, set continue to false, to make sure this form is not saved.

Upvotes: 0

teleman
teleman

Reputation: 940

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.

Upvotes: 2

Related Questions