I successfully change field values using replaceitemvalue in document B in databse B based on a field value in document A in database A. (Fields tab in document properties box shows the new vlaues. However, the problem is that the document B does not show the new values when opened for viewing unless and until refreshed or saved again. I have tried using view.refresh but doesn’t seem to work. Any genius in here to suggest a solution? Oh, just to mention, I am using ‘call’ methods in querysave object of document A to replace and refresh values in document B???
By the way, what does (True, True) or (True, False) or any combination for that matter means for instance call doc.save(True, True)?
Thanks Michael. I don’t think I can because the the document B is not always just one document but can be a number of documents together. I do collections of related document Bs in database B and loop through each of those and change corresponding field values. Good thing is that the code does replace the field values but new value does not display until each or all of those documents have been batch refreshed.
Subject: How to force or automate document/fields to refresh?
from HELP.
If true, the document is saved even if someone else edits and saves the document while the program is running. The last version of the document that was saved wins; the earlier version is discarded.
If false, and someone else edits the document while the program is running, the makeresponse argument determines what happens.
Subject: RE: How to force or automate document/fields to refresh?
You said, the document B does not show the new values when opened for viewing … until refreshed or saved again.
This doesn’t sound like a view refresh issue. It sounds to me like there are some computed fields on the form that you need to have recalculated.
Saving changes using NotesDocument.Save, does not recalculate computed fields and field translation formulas. It only changes the fields you specifically asked to change. The form is only used ewhen editing a document on screen.
You can apply the computed field formulas and input translation formulas using NotesDocument.ComputeWithForm.
Another thing you might look at, is whether you can change some of the fields from Computed to Computed For Display, forcing them to be recalculated every time the document is opened (however, you will need to write a little agent to remove the stored values from all your current documents.
Subject: RE: How to force or automate document/fields to refresh?
Hello Andre,
Well done. You are spot on. There are some computed fields on that form that are in fact recalculated based on the new value that I replace as I described before. Are you sugessting that once I have done
Set item = doc.replaceitemvalue(“FIELD”, NewValue)
I should do
doc.Form = “TheFormName”
call doc.ComputeWithForm(False, False)
The other thing you suggested is to use ‘Computed for display’ fields instead. I can’t do that cos the value of those fields are used in view columns.
Subject: RE: How to force or automate document/fields to refresh?
That should work; though you needn’t assign the Form field for an existing document, since the Form field is already set.
As far as displaying your computed fields in a view, yes, that would be an obstacle to making them CFD. If they don’t use certain functions (e.g. @DbLookup) and if the formulas are not complex (for performance reasons) you could just use the same formula in the view column and then you wouldn’t have to store them.
If you’re doing an @DbLookup to populate these fields, do you have a process in place to update them if the data that you’re looking up changes?
The view.refresh is used to refresh the back end, since the notesview object is a back end object.
You have to use "NotesUIWorkspace.ViewRefresh".
The Help file in R5 says: "To refresh the view on the user screen, first call
Refresh method, then call the ViewRefresh method of NotesView." -- NOTE the
last word should read "NotesUIWorkspace", since that is the object that
ViewRefresh refers to!