Attempt to execute nested form events - in saving new version

Hi,

I get the error " Attempt to save nested form events" when I try to save the a new version of the form.

Here is the code which I have in Query Save event:

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim uidoc As NotesUIDocument

Dim dateTime As New NotesDateTime( “Today” )

Dim workspace As New NotesUIWorkspace

Dim GrantorType As String

Dim Grantor_1Type As String

GrantorType = Source.FieldGetText(“Grantor”)

Grantor_1Type = Source.FieldGetText(“Grantor_1”)

Set uidoc = workspace.CurrentDocument

If source.IsNewDoc = True Then

Call uidoc.FieldSetText( "Grantor_1", GrantorType )

Call uidoc.save

Else

Call uidoc.FieldSetText(“Modifications”,“”)

Call dateTime.AdjustYear(-1)

Call uidoc.FieldSetText(“FirstName”, “”)

Call uidoc.FieldSetText(“LastName”, “”)

Call uidoc.SaveNewVersion

Call uidoc.FieldSetText(“Form”, “New Info”)

Call uidoc.save

Call uidoc.Close

answer% = Messagebox(“Your new form created.”,0 ,“Process Complete”)

End If

End Sub

Subject: Attempt to execute nested form events - in saving new version

You can’t call uidoc.Save from the QuerySave, since it invokes the QuerySave event, which calls uidoc.Save, which invokes the QuerySave event, which call uidoc.Save, which…

Subject: RE: Attempt to execute nested form events - in saving new version

Thanks for your reply. But how can i save a new version of document in save event.

Subject: RE: Attempt to execute nested form events - in saving new version

Huh? The document is on its way to being saved. Any changes you make in the QuerySave code will automatically be saved – there is no “new version”, just the document that is being saved anyway.

Subject: RE: Attempt to execute nested form events - in saving new version

This means we can save only any other doc other than uidoc in Query Save?

Subject: RE: Attempt to execute nested form events - in saving new version

You can create (or edit) and save as many documents as you like in the QuerySave, but you cannot explicitly save the current UI document because it is already being saved. The QuerySave event happens between the time that a sve of the UI document is called and the time that the document is actually saved. That gives you a chance to update fields and so on, but most importantly, it gives you a chance to cancel the save if something is not right. Because of when the code happens, you cannot call a save of the UI document from the QuerySave.

Subject: RE: Attempt to execute nested form events - in saving new version

Thanks for your great reply Rogers…

My requirement is below:

I have a buton called “archive new”.

I open document, change any field which is already entered and click ‘save and close’ button

So when I do this certain fields will be compared with old ones

and if any change then pop up a msgbox if user wants to archive or not.

If yes then old one will be archived and new one will have diff field value which I have entered.

How to code for the same in Query Save ?

Pls help.

Subject: RE: Attempt to execute nested form events - in saving new version

You are handling the process at the wrong point. If the aim is to archive the original document, then archive the original document at the beginning (when the “archive” button is clicked). You can then make a copy of the original document (using CopyAllItems) and allow the user to make changes to the new copy.