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

Question

Question

CAT (CustomButtonManagerApp) and Evaluate for EntryInfo "isLocked"

SDK
asked on November 6, 2017

I'm updating a CAT project from LF9x to 10.2 and I've noticed that the following line (for debugging purposes) always returns a value of False for each.  

MsgBox(EI.Name.ToString & " | " & EI.Id & " " & "LockVal: " & EI.IsLocked & "  PendingVal: " & EI.IsPending & "  ModVal: " & EI.IsModified)

I need to establish if the document has been changed before I update the image or metadata.  Currently in this version of the toolbar add-in, the if statement "If EI.IsLocked Then" is never triggered 

Ideally, I'd like to save the entry without prompting the user to do so within the client.

Anyone working with CustomButtonManager in 10.2?

 

0 0

Answer

SELECTED ANSWER
replied on November 6, 2017 Show version history

EntryInfo.IsLocked returns whether that particular EntryInfo object holds a lock on the entry (not whether it is locked by anyone). Use this helper method to determine if the entry is locked by the current user:

    Function IsEntryLockedByMe(ByRef en As EntryInfo)

        Dim elSettings As New EntryListingSettings
        elSettings.AddColumn(SystemColumn.LockOwnerSid)
        elSettings.AddColumn(SystemColumn.LockOwnerName)

        Dim listing As SingleEntryListing = New SingleEntryListing(en.Id, elSettings, en.Session)
        Dim lockOwnerSid = listing.GetDatum(1, SystemColumn.LockOwnerSid)

        'Dim lockOwnerName = listing.GetDatum(1, SystemColumn.LockOwnerSid)

        IsEntryLockedByMe = lockOwnerSid = en.Session.UserIdentity
    End Function

To save the document in the doc viewer, you can use SendMessage:

    Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
    Private Const ID_FILE_SAVE As Integer = &HE103
    Private Const WM_COMMAND As Integer = &H111

    Sub SaveDocViewer(ByRef docViewer As DocumentViewer)
        SendMessage(docViewer.Hwnd, WM_COMMAND, ID_FILE_SAVE, Nothing)
    End Sub

 

0 0
replied on December 4, 2017

What would the equivalent of

Private Const ID_FILE_SAVE As Integer = &HE103

be in C#?

0 0
replied on December 5, 2017

try this:

    [DllImport("user32.dll", EntryPoint="SendMessageA")]
    private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, string lParam);
    
    private const int ID_FILE_SAVE = 57603;
    
    private const int WM_COMMAND = 273;
    
    void SaveDocViewer(ref DocumentViewer docViewer)
    {
        SendMessage(docViewer.Hwnd, WM_COMMAND, ID_FILE_SAVE, null);
    }

When you are unsure of how to convert, use a tool like CodeTranslator

2 0
replied on December 5, 2017

Thanks Bert!!

0 0

Replies

replied on November 6, 2017

Excellent, those worked perfectly 

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

Sign in to reply to this post.