Conflict during document save

Hi! I have a problem during document save. I developed a function that update a document in back-end (using notesDocument as parameter). If I run this function while I am in edit document of document that will be updated by it, I get a “another copy of this document…” message after QuerySave event. I can’t do differently, like invoking this function from uidoc!

I’d like to know how and if it’s possibile to check if document has been modified in back-end by other procedures (agents) or users. If so, is it possibile to update uidoc reloading its back-end document from database?

Thank’s in advance!