This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Jun 23, 2015, 1:39 PM
18 Posts

Identify Current User Who Has Document Open in UI

  • Category: Domino Designer
  • Platform: Windows
  • Release: 9.0.1
  • Role: Administrator,End User
  • Tags: User document
  • Replies: 7

I am trying to work out how to identify the username of the person who currently has a document open in the UI. I know I can determine if the uidoc is open but need to know by who (using lotus script).

 

Any ideas?

Jun 23, 2015, 5:22 PM
107 Posts
Just curious
How do you find out, in general, whether a front-end doc is open for a given back-end doc using LotusScript?

I've been struggling with this in the past, but never found a satisfying solution -- except for the very limited use case when the back-end document object was obtained from a front-end document object (in which case the user would always be the current user).
Jun 24, 2015, 4:44 AM
18 Posts
Front End Doc is Open

Hi Jochen,

Extract straight out of notes Help file.

IsUIDocOpen (NotesDocument - LotusScript®)

Read-only. Indicates whether a NotesDocument object (back-end document) is accessed through a NotesUIDocument object (front-end document).

Defined in NotesDocument

To get: flag = notesDocument .IsUIDocOpen

  • True indicates that the back-end document is from a front-end document.
  • False indicates that the back-end document is not from a front-end document.

Example

Sub UpdateSubject(doc As NotesDocument)
  If doc.IsUIDocOpen Then
    Messagebox _
    "Can't do Subject update from front-end",, _
    "No can do"
    Exit Sub
  End If
  Call doc.ReplaceItemValue _
  ("Subject", doc.Subject(0) & "0")
  Call doc.Save(True, False)
End Sub
Jun 24, 2015, 6:02 AM
107 Posts
Thanks for clarifying...
The NotesDocument.IsUiDocOpen property is what I meant by 'limited use case'. It only works if the NotesDocument object was obtained by invoking NotesUiDocument.Document. It does not allow you to find out whether a UI document is open in case the NotesDocument object was obtained through a database search or view lookup.

Regarding your original question, if the NotesDocument object was in fact obtained by invoking NotesUiDocument.Document, then the user is always the current user (i.e. NotesSession.UserName), right?
Jun 24, 2015, 3:36 PM
100 Posts
Depends on what you're trying to do.

I think if you turn on doc locking, you get a notice when you try and open/edit a document. I don't use this very often so YMMV.

I have an app where I want to explicitly lock a doc (or set of docs that share some attribute) and make it clear who owns the lock. In that case, I have a function to let a user lock the doc (or doc set). The function sets a field with their name and that data is displayed in the view. If the view isn't fresh for some user, when they attempt to open or edit the doc, they get a pop-up that lets them know it's locked and who to see.

If you have something specific you want to do/have happen and what I posted doesn't help, can you provide more info?

Jun 25, 2015, 2:44 AM
18 Posts
More Specific Information

I think you are correct Jochen.

Doug, to give a little more detail. In my application a document can be opened and edited as normal. I have a few routines that run in other areas of the database that will update the document. If someone happens to be editing the document when the routines run and update the document, when the user who has the document open goes to save the document you get the warning message regarding "someone saved another version of this document since you opened it .... Do you want to create a replica or another copy....." I am trying to avoid this situation by not allowing the routines to update the document whilst it is being edited in the UI.

Jun 25, 2015, 9:45 AM
107 Posts
I see. Had a different use case in mind...
I was thinking of the case where a local agent modifies a document. To avoid save conflicts, and/or to have changes made by the agent be reflected in the front-end, it would be desirable to know whether the same document is currently open in the UI -- edit mode or not. Unfortunately I don't know of a reliable method to achieve that.
Jun 25, 2015, 4:13 PM
100 Posts
How about this? - sorry about the dups

No clue why this is happening, I'm hitting 'save' one time. Guess my replies are twice as good!

I understand the 'front end/back end collision' issue.

I have this bit of code in an agent that's supposed to prevent rep/save prompts

flag = doc.Save(False, False)

If flag = False Then

' This means another user edited the doc while the agent was also trying to, so go back to the beginning of this function and try again.

'loop back and try again

End If

 

You could also create a temporary 'lock doc' when the user puts it into edit mode and have your code check for the lock. The lock clears when the person exist the doc.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal