0
votes

I have an error on a computed for display text field. For Each document, i open it in edit mode and resave to correct it. I have the same problem on many databases and documents. I tried to correct it with an agent over the entire base with the function EditDocument in uiworkspace . As follows:

Option Public
Option Declare

Sub Initialize

Dim session As New NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim view As NotesView
Dim doccand As NotesDocument
Dim doc As NotesDocument
Dim result As Integer
Dim uiwks As New NotesUIWorkspace
Dim uidoc As NotesUIDocument

Set db  = session.Currentdatabase
Set col = db.Unprocesseddocuments
Set docCand =  col.getfirstdocument

On Error Resume next

While Not docCand Is Nothing
    Set uidoc =  uiwks.Editdocument(True, docCand)
    Call uidoc.save
    Call uidoc.close(True)
    Set docCand =  view.getNextdocument(docCand)
Wend

End Sub

This function corrects the problem only when I start it from my Notes client. It does not work as a scheduled task in the domino server. I tried with computewithform without uiworkspace and it does not work either. Anyone have a method to refresh with edit and save document in scheduled agent?

2
If it's computed for display, it's not saved and it gets recalculated every time someone opens the document to read. If you've corrected the formula, nobody should see the error s I don't really see the point of refreshing.Richard Schwartz
It's a computed for display field and it's saved on the last document save. i have to switch to edit mode to see the correction.user3082877
The difference between a computed field and a computed for display field is that computed for display fields are NOT saved to the document and are computed ONLY when you open the document for display.David Navarre

2 Answers

4
votes

computed for display text field

Such type of fields are not saved in documents, it's kind of same thing as a Computed Text.

About your solution:

NotesUIWorkspace and EditDocument can't be use in a schedule agents that run in background (i.e. on server)but only from UI (that's why it works when you run LN).

What you need to do is to use ComputeWithForm method from NotesDocument. It will refresh documents in background (no need to open/save it).

While Not docCand Is Nothing
    Call docCand.ComputeWithForm(False, False)
    Call docCand.save
    Set docCand = col.getNextdocument(docCand)
Wend

Notice, in your script there is an issue, you are trying to get next document from a view which is not initialized. I guess you want to use col instead.

Set docCand =  view.getNextdocument(docCand)
1
votes

Computed for display fields are not supposed to be saved. You should not have to do a refresh.

There is only one circumstance that I know of in which the value of a computed for display field is saved. It happens when the field on the form is originally designed as a regular computed field, but then someone changes it to computed for display. The original computed fields were saved as items in the stored document, and even after the field is changed to computed for composed Notes will continue to see the saved value. If that's what's happening, then what you really want to do is run an agent to delete the saved values. E.g.,

FIELD myFieldThatUsedToBeComputedButIsNowCFD := @DeleteField;