editDocument method changes creation date

Hello there.I’ve created an agent to re-edit and resave all document in a view automatically when clicked. I used the method editDocument to do the editing. I also have a date field that used @Created formula language to record the time the document is created for filing purposes. I noticed that when a document is opened and resaved back using the editdocument method, it changes the creation date of the document to the date the agent is clicked.

For example, lets say I opened a document that was created on January 1st, then I click on the agent to resave that document today, the creation date field will be changed to April 8th.

Here’s a portion of the code:

Dim session As NotesSession

Set session = New NotesSession

Dim db As NotesDatabase

Set db = session.Currentdatabase

Dim view As NotesView

Dim changeField As String

Set view = db.GetView("Main Form")

Dim doc As NotesDocument

Dim maintainDate As String

Set doc = view.GetFirstDocument

While Not ( doc Is Nothing )

	

	Dim workspace As New NotesUIWorkspace

	Dim uidoc As NotesUIDocument

	Set uidoc = workspace.EditDocument(True,doc)

	

	

	Call uidoc.Save



	

	Call uidoc.Close(True)

	Set doc = view.GetNextDocument( doc )

Wend

End Sub

Thanks for the attention :slight_smile:

Subject: editDocument method changes creation date

maybe the following will help…don’t use UI function, just NotesDocument:

Dim doc1 as NotesDocument

while not (doc is nothing)

Set doc1 = view.GetNextDocument(doc)

doc.ComputeWithForm(False, Flase)

Call doc.Save(True, True)

Set doc = doc1

Wend

Subject: RE: editDocument method changes creation date

hello eleksey, thank you for the coding samples. I will try it out soon. I’ll give you the feedback once I am done. Again, thank you so much :slight_smile:

Subject: editDocument method changes creation date

what are all of the properties of your Date field? For example: is it computed, computedwhencomposed, other? Is it a Date or Text field? Tell us ALL properties.

Subject: RE: editDocument method changes creation date

It’s a computed only field, and I used @Now/ @Created to generate the date. It is date-type of field. Hope that explains.

Subject: RE: editDocument method changes creation date

If you are using @Now in a Computed field the date will change any time you resave the document. A field that shows the created date only needs to be ComputedForDisplay with @Created as the formula. If you need to reference the field outside of the UI you should make it ComputedWhenComposed and use @Now. The field will then only compute the date once when the doc is composed.