You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Entry Lock Information Not Returning in SDK

posted on October 5, 2021

When I lock a document in Laserfiche and then try to get the lock information through calls to the RepositoryAccess SDK, the lock information is not being returned. I have tried locking documents through the LF Client and through the SDK, and I have tried admin users, the user who locked the document, and a different user. All calls return no lock information. I have tested with multiple Laserfiche 11 Servers, using both the RA 10.2 and 10.4 toolkits with no success. Is this a known bug or am I trying to retrieve the lock information incorrectly?
 

    private static void TestLock(string lfServer, string lfRep, string lfUser, string lfPwd, string entryId)
    {
      Server serv = new Server(lfServer);
      RepositoryRegistration rep = new RepositoryRegistration(serv, lfRep);
      Session session = new Session();

      if (string.IsNullOrWhiteSpace(lfUser))
        session.LogIn(rep);
      else
        session.LogIn(lfUser, lfPwd, rep);

      DocumentInfo lfEntry = (DocumentInfo)Entry.GetEntryInfo(entryId, session);

      EntryListingSettings els = new EntryListingSettings();
      els.AddColumn(SystemColumn.LockOwnerName);
      SingleEntryListing listing = new SingleEntryListing(lfEntry.Id, els, session);
      string userName = listing.GetDatum(1, SystemColumn.LockOwnerName).ToString();

      Console.WriteLine(userName);                      // userName = ""

      Console.WriteLine(lfEntry.IsLocked);              // false
      Console.WriteLine(lfEntry.IsCheckedOut);          // false

      if (lfEntry.EntryLock != null)                    // EntryLock = null
      {
        Console.WriteLine(lfEntry.EntryLock.IsActive);  // false
        //Console.WriteLine(lfEntry.EntryLock.Comment);   // Unavailable in 10.4
      }

    }

 

0 0
replied on October 5, 2021

What are you trying to accomplish? The EntryLock property on EntryInfo represents the lock held by that instance of the entry, so it will be null if that EntryInfo isn't the one that locked the entry.

 

You can get the lock details for an entry using EntryLockListing.GetListing:

EntryLockListingSettings lockListSettings = new EntryLockListingSettings();
lockListSettings.IdentityReference = null; // Set the SID to get all locks for a specific user.
lockListSettings.PersistentLocksOnly = false; // Set to true to exclude ephemeral (aka temporary) locks.
using (EntryLockListing lockList = EntryLockListing.GetListing(10, lockListSettings, session))
{
    for (int i = 1; i <= lockList.RowCount; i++)
    {
        EntryLockListingRow row = lockList.GetRow(i);
        int entryId = row.EntryId;
        string lockComment = row.Comment;
        string lockUserSID = row.Sid.ToString();

        // To remove the lock:
        //Entry.Unlock(row.EntryId, row.LockToken, session);
    }
}

 

2 0
replied on October 5, 2021

Thank you, we have switched to using the SystemColumn.PLockOwnerName column, and we now know the EntryLock property only reflects the lock status of that instance of the EntryInfo, not the lock status of the entry in the repository.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.