Find out who has lock for sections in shareable edit mode?

I wrote a simple Layout DXL that basically shows me the locked state of every object in shareable edit mode. However its a bit limited. I know if things are locked, and I know if the current user has a lock.
Does anyone know of a way to find out who has a lock if canLock() fails?

e.g.

pragma encoding, "UTF-8"

// See if we can lock the object, if we can then it is unlocked
if (canLock(obj)) then
{
display("Unlocked")
}
else
{
// See if we have the lock or someone else has it.
if (isLockedByUser(obj)) then
{
string Me = doorsname()
display("Locked by " Me)
}
else
{
display("Locked")
}
}

So instead of printing Locked in the last else, I would like,

string LockedBy = doorsLockedByUser???
display("Locked by " LockedBy)

  • Tom

Atomic007 - Fri Jul 13 13:54:21 EDT 2012

Re: Find out who has lock for sections in shareable edit mode?
Atomic007 - Mon Jul 30 14:33:09 EDT 2012

Anyone? I guess it can't be done?

I know Doors knows who has the lock if you click a locked item, just wish it was exposed in DXL.

Re: Find out who has lock for sections in shareable edit mode?
llandale - Mon Jul 30 15:37:09 EDT 2012

Here is some unfinished work I did a few years ago. I have a nagging memory that you could not find out if someone else ALSO had the module open Shared.

string LockModes[] = {"0-lockRemoved", "1-lockShare", "2-lockWrite"}
 
 
string    BuildLockInfo(Lock lck)
{     // build a string summarizing the lock
        Item    itm      = lck.item
        string  NameFull         = fullName(itm)
        string  UserLock     = lck.user
        string  ResourceLock = lck.resourceName
        string  Computer         = lck.host
        int     ProcessID        = lck.connectionId
        string          ID               = lck.id
        int     Mode             = lck.lockMode
        Date    DateLock     = lck.date
        
        return("User: " UserLock " \t" Computer " \t'" ResourceLock "'("NameFull ") \t" LockModes[Mode] " \t" ProcessID "\t" DateLock "")
}     // end BuildLockInfo()
 
 
        Lock    lockItem
        string  UserLock, ResourceLock, ErrMess
        LockList        llist = getLocksInFolder(folder ("/"), true, true)
        for lockItem in llist do
        {  print BuildLockInfo(lockItem) "\n"
        }
        delete(llist)


and...

 

void    PrintLocksInModule(ModName_ mn)
{
        LockList        lcklst = getLocksInModule(mn,false)
        Lock    lck
        string  s, NameUser, lt, scnResTemp = ""
        int     i
        User    usr
        print "before loop\n"
        for lck in lcklst do
        { 
           print "in loop\n"
           s = lck.user
           i = lck.lockMode
           if     (i == lockShare)      lt = "Shareable"
           elseif (i == lockWrite)      lt = "Exclusive"
           elseif (i == lockRemoved)    lt = "Removed"
           else                         lt = "Bad LockMode Found: [" i "]"
           if (existsUser(s))
           {
              usr = find(s)
              NameUser = usr.fullName
              if (NameUser == null)
                   NameUser = "No FullName"
           }
           scnResTemp = scnResTemp s "\t\t" NameUser "\t\t\t" lt "\n"
        }
        print "[" scnResTemp "]\n"
}    // end PrintLocksInModule()
 
Module  mCurr = current
ModName_        mn = module(fullName(mCurr))
 
PrintLocksInModule(mn)


-Louie

 

Re: Find out who has lock for sections in shareable edit mode?
BeastBoysDad - Fri Aug 01 14:14:58 EDT 2014

Try this:

 

Object curObj = current
string lockErrorMsg = lock (curObj)
if (!null lockErrorMsg) print lockErrorMsg "\n"
else print "Lock succeeded\n"

 

I obtained the following successive results:

 

Item /My_Project/My_Formal_Module locked (unshared) by Jane Doe@computerName1 at 08/01/14 10:25:02
Lock succeeded
section already locked
Item /My_Project/My_Formal_Module locked (unshared) by John Smith@computerName2 at 08/01/14 11:03:59