Edwin Krause
Edwin Krause

Reputation: 1806

Lotus Notes: Creating new document with prefilled fields, opening in edit mode without saving

I have an issue I don't quite understand and I'm struggeling with it for quite a while now.

From an existing document I want to create a new document (same DB different form). I use a button inside this form.

Sub Click(Source As Button)
    Dim ws As New NotesUIWorkspace
    Dim thisProject As New kitcProject() '// this only wraps the current document
    Set NREDOC = thisProject.newNREdocument() '// this returns a NotesDocument, that has not been saved yet
    Call ws.EditDocument(False, NREDOC, False, "", True, False)
End Sub

This is not working, it does not open the document unless I save it first before using the EditDocument call

    Call NREDOC.Save(true, false)

I have a similar button function that works fine with a document from another database, that is also in unsaved state when opening it with the EditDocument call.

Here is the function that returns the NREDOC

%REM
Function newNREdocument
Description: Returns a new NotesDocument prefilled of type NRE
%END REM
Public Function newNREdocument() As NotesDocument
    Set me.nreDoc = db.Createdocument()
    With me.nreDoc
        .Form = "NRE"
        .nreProjectID = me.uidocument.FieldGetText("prProjectID")
        .nreProjectName = me.uidocument.FieldGetText("prProjectName")
    End with
    Set newNREdocument = me.nreDoc
End Function

Checking the NREDOC in Debug Mode tells me that there is nothing wrong with the document, ParentDatabase is set correctly, all the prefilled values are set, but it won't open. What am I doing wrong?

Is there some flag to be set in the form properties maybe? I have no further ideas

Thanks for your help in advance.

Upvotes: 0

Views: 1074

Answers (2)

D.Bugger
D.Bugger

Reputation: 2359

You could also make the new document show up in a DialogBox, so everything stays on the same screen and access to the first document is blocked. The only thing different there would be way to save the new document. Quite interesting actually...

Upvotes: 0

Edwin Krause
Edwin Krause

Reputation: 1806

I found the solution. The key here is the newInstance flag at the end

Call ws.EditDocument(True, NREDOC, False, "", False, True)

Setting the flag to True solved my issue. Unfortunatelly that was the last flag I was playing around with.

Upvotes: 1

Related Questions