uidoc.Refresh saving document

I’ve just come across something which I don’t understand (not unusual, especially on a friday). I have quite a complicated form accessed by the Notes client. In the postopen event I have a bunch of Lotusscript which fills a load of fields in if necessary, and as a final step, refreshes the uidoc using Call source.Refresh(True). I just noticed this morning that when that line of script executes, if I’m watching the IsNewDoc property of Source in the debugger, it switches from True to False at this point, completely bypassing all my QuerySave script which checks for values in mandatory fields.

I checked the form for translation formulas, postrecalc formulas and I can’t find anything in there which would be causing the document to save on a Refresh. The funny thing is, when I switched the IncludeRichTextItems flag from True to False, it stopped happening. I double checked all the rich text fields for rogue code but still couldn’t find anything. I’ve also found that it’s happening on 3 other forms which use similar code in the PostOpen events.

Now, I have got the problem fixed by not including rich text items in the refresh, but I’d like to get to the bottom of this. If anyone has seen this type of behaviour before and managed to find the root cause, I’d be really interested to hear from you. And please don’t hesitate to suggest something that may seem obvious, I often overlook the simple in the belief that my problem must be really complex :wink:

Thanks,

Emily.

Subject: uidoc.Refresh saving document

I tried to reproduce your problem. But I could not. But I have another effect which I do not understand and which may be connected to your problem.If I set the RTI flag to true I lose the content of the RTI on the refresh line. If set the flag to false the RTI item keeps its content.

But in either way the RTI item loses its content when the document is finally opened.

Maybe this helps you a little bit

Following is the code of my Postopen event.

Sub Postopen(Source As Notesuidocument)

If (source.IsNewDoc) Then

	Dim doc As NotesDocument

	Dim rti As NotesRichTextItem

	

	'*** refresh to have items set in the doc of the uidoc

	Call source.Refresh(True)

	

	'*** set the back end doc

	Set doc = source.Document

	

	'*** get the rti

	Set rti = doc.GetFirstItem("RTI")

	

	rti.AppendText("Just a line 1")

	rti.AddNewline(2)

	rti.AppendText("Just a line 2")

	

	'*** set field values

	Call doc.ReplaceItemValue("Test", "This is a new document")

	

	Call source.Refresh(False)

End If

End Sub

Subject: RE: uidoc.Refresh saving document

Hi Christian,

That looks the type of problem that if I stumbled across it by accident I’d spend about 7 hours of hair pulling trying to find out what was going wrong before seeing what was causing it! I think it would be interesting to know exactly what Domino does with the rich text items when you call refresh on the uidoc. As usual, Designer help is a wee bit sparse on the detail :slight_smile: Can’t help feeling that that my problem and the one you found might be related. though.

Thanks for taking the time to have a look at this - i really appreciate it.

Emily.