Everything about Domino, PHP and other programming languages

How to get a handle to the updated backend document without re-opening the ui document

Cor Eigenhuis  March 10 2010 11:07:23 AM
While working on a project for a customer we've encountered a strange behaviour when trying to get a handle to the backend version of an open document in de UI. Below is a small case example with our workaround.

Workflow:

An ui document (not in edit-mode) is updated by code run from an inview-edit code on a response document ("Grondstof") within the embedded view on the ui document (A). These response document are automatically created by action "B".

A. Remove response document and update the parent (current ui) document by removing the "Grondstof" number (unique number for the child) from an array.
B. Runs a script which adds on or more new "Grondstof" responses. The array on the parent document is used for making sure no double response documents are created (the array has some other uses too).


Image:How to get a handle to the updated backend document without re-opening the ui document

Problem:

When running the script for action "B", getting the backend document by using uidoc.Document is not satisfactory. The backend document did not receive the updates by the inviewedit. On the screenshot below you can clearly see a difference, even though all code is referring to the same document.


Image:How to get a handle to the updated backend document without re-opening the ui document

Solution:

So instead of getting the backend document by using uidoc.Document, try:
Set doc = unidview.GetDocumentByKey(Cstr(uidoc.Document.UniversalID))


Make sure that the view 'unidview' is sorted on the UNID of the document(s) (with @Text(@DocumentUniqueID)).

This will make sure that your document contains the correct data, and that a handle can be made.
Comments
No Comments Found