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

Question

Question

Workflow Script Activity

asked on April 6, 2022

Hi,

Use Case: Repository has a shared configuration folder , which is being used by the several audiences thus sometimes seems locked as users forget to close the screen when updating. 

 

I have applied a check in the SDK script of workflow to  unlock the folder when before updating but it fails to unlock  errors stating the folder is lock on the update field activity.

 

WorkflowApi.TrackInformation("Check if the Entry" +  myEntry.Id + " is locked   "+ myEntry.IsLocked);

myEntry.IsLocked : False

 

Although through LF Admin console , release lock is possible.

 

Please suggest , we have unlock() method on the entry in SDK(myEntry.Unlock()) thus assume unlocking possible , is my understanding correct . If not please let me know the alternate way through SDK.

0 0

Answer

SELECTED ANSWER
replied on April 6, 2022

You can unlock entries, but you need the Entry ID, the Lock Token, and a Session that is logged in with administrative rights.

In your main Execute, you can add:

Dim iEntID As Integer = myEntry.Id
' Get the LockTocken from the entry
Dim sLockToken As String = GetLockToken(iEntId)
' Only process if the LockToken is not empty
If Not String.IsNullOrEmpty(sLockToken) Then
	Entry.Unlock(iEntID, sLockToken, RASession)
End If

Then add the following function:

    Private Function GetLockToken(ByVal iEntryID As Integer) As String
        Dim sReturn As String = Nothing
        Dim els As EntryLockListingSettings = New EntryLockListingSettings()
        els.PersistentLocksOnly = False
        Using ell As EntryLockListing = EntryLockListing.GetListing(1000, els, RASession)
            For Each ellr As EntryLockListingRow In ell
                If ellr.EntryId = iEntryID Then
                    sReturn = ellr.LockToken
                    Exit For
                End If
            Next
        End Using
        Return sReturn
    End Function

Note:  There may be a better way to get the LockToken, but this is what I have found.

2 0

Replies

replied on April 6, 2022

The unlock method releases locks you acquired, not other users' locks.

0 0
replied on April 6, 2022

Then LF admin console is only option of releasing lock. Do LF admin console offer any  Library?

0 0
SELECTED ANSWER
replied on April 6, 2022

You can unlock entries, but you need the Entry ID, the Lock Token, and a Session that is logged in with administrative rights.

In your main Execute, you can add:

Dim iEntID As Integer = myEntry.Id
' Get the LockTocken from the entry
Dim sLockToken As String = GetLockToken(iEntId)
' Only process if the LockToken is not empty
If Not String.IsNullOrEmpty(sLockToken) Then
	Entry.Unlock(iEntID, sLockToken, RASession)
End If

Then add the following function:

    Private Function GetLockToken(ByVal iEntryID As Integer) As String
        Dim sReturn As String = Nothing
        Dim els As EntryLockListingSettings = New EntryLockListingSettings()
        els.PersistentLocksOnly = False
        Using ell As EntryLockListing = EntryLockListing.GetListing(1000, els, RASession)
            For Each ellr As EntryLockListingRow In ell
                If ellr.EntryId = iEntryID Then
                    sReturn = ellr.LockToken
                    Exit For
                End If
            Next
        End Using
        Return sReturn
    End Function

Note:  There may be a better way to get the LockToken, but this is what I have found.

2 0
replied on April 8, 2022 Show version history

Hi Bert,

Above code has been helpful . Can you please provide me with SDK documentation around EntryLockListingSettings .

Especially : GetListing first Parameter

EntryLockListing.GetListing(1000,els,this.RASession)

 

 

0 0
replied on April 8, 2022

The only documentation that I have is in the SDK help file.  If you own the SDK, then you can look in the .net help file under:

Laserfiche.RepositoryAccess
  -EntryLockListing Class
    -EntryLockListing Methods
      -GetListing Method

1 0
replied on April 8, 2022

It should be noted that you won't know if the user is still in the middle of edits and the behavior may be unpredictable when they try to save after you removed their lock.

It might be better for the user experience if you set inactivity timeouts for users in the repository and extended the retry interval in Workflow or the number of retries.

1 0
replied on April 8, 2022

Considered above scenario

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

Sign in to reply to this post.