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

Question

Question

Open Metadata via CAT?

SDK
asked on October 11, 2016 Show version history

Using CAT, is it possible to open the Metadata dialog box for a specific entry (assuming my program has the entry's ID as a variable).

Use-Case: Workflow creates standardized "order" folders inside our repo. An order folder has a bunch of sub-folders and files inside of it, but everything within the folder corresponds back to the same order. What I need is a button on the Laserfiche Client toolbar that, when clicked, says to itself, "I know what entry currently has focus, but I'm going to navigate up the folder structure until I find a parent folder with a specific template, because then I will have found the order in question's master folder. Once I find this folder, I will then open the Metadata dialog box for that folder for the user to see."

The problem that I'm aiming to solve with this button is purely around usability. Users are often deep into an order folder's sub-folders, and then realize that they need to view/edit the metadata for the master order folder. Navigating back to the master folder to open its Metadata dialog box is annoying to them.

Is such a button possible? I'm not seeing any hooks to pull this off in CAT, but I thought I'd check.

0 0

Replies

replied on October 11, 2016 Show version history

Call MainWindow.OpenDocumentById and specify OpenStyle=DocumentOpenType.Metadata. You can also specify which tabs to show, the initial tab, and the dialog position. See the LDEV203 sample code for an example.

Edit: Even though the method is OpenDocumentById, it works for folders when you use it to view the metadata dialog or preview pane.

0 0
replied on October 12, 2016 Show version history

Thanks Robbie! That worked perfectly.

In case anyone is interested, here is the code I ended up using (in VB.NET; the formatting doesn't look great below):

'Create global variables.
Dim skipFinalErrorMessage As Boolean = False

Using lfclient As New ClientManager()

'Get all Laserfiche Client instances that are open on the machine.
Dim clients As IEnumerable(Of ClientInstance) = lfclient.GetAllClientInstances()

'Iterate over each open Laserfiche Client.
For Each client As ClientInstance In clients
	
'Only proceed if the Laserfiche Client is logged in.
	If client.IsLoggedIn = True Then
		
'Get the Laserfiche Client's open windows.
		Dim windows As IEnumerable(Of ClientWindow) = client.GetAllClientWindows()
		
'Iterate over each window.
		For Each window As ClientWindow In windows
			
'Retrieve the Laserfiche Client's connection.
			Dim repoConnection As RepositoryConnection = window.GetCurrentRepository
			
'Only proceed if a connection was successfully retrieved.
			If Not repoConnection Is Nothing Then
				
'Clone the retrieved connection.
				Dim currentSession As Session = Session.CreateFromSerializedLFConnection(repoConnection.GetSerializedConnection)
				
				If window.GetWindowType = ClientWindowType.Main Then
					
'Get the "main" window.
					Dim mainWindow As MainWindow = TryCast(window, MainWindow)
					
					Try
					
'Get the active entry's path.
					Dim currentEntryInfo As EntryInfo = Entry.GetEntryInfo(mainWindow.GetCurrentFolderId, currentSession)
					
'Attempt to find an order number within the active entry's path using regex.
					Dim regex As Regex = New Regex("\\Operations\\Active Orders\\Order (\d+) - .+")
					Dim match As Match = regex.Match(currentEntryInfo.Path)
					
'If an order number can be found, use it get the appropriate order folder and open its metadata.
'Otherwise throw an error.
					If match.Success Then
						
'Minimize this program.
						Me.WindowState = FormWindowState.Minimized
						
'Open the order folder's metadata.
						Dim options As New OpenOptions()
						options.OpenStyle = DocumentOpenType.Metadata
						mainWindow.OpenDocumentById(match.Groups.Item(1).Value, options)
						
						skipFinalErrorMessage = True
						
					Else
						
						MessageBox.Show("Could not find an order folder." & Environment.NewLine & Environment.NewLine & "Ensure that you are currently inside of a green order folder, then try again.", "View Order Metadata", MessageBoxButtons.OK, MessageBoxIcon.Warning)
						
						skipFinalErrorMessage = True
						
					End If
					
					Catch ex As Exception
					
					MessageBox.Show("Uh oh! Something went wrong." & Environment.NewLine & Environment.NewLine & "Contact your Laserfiche administrator for help.", "View Order Metadata", MessageBoxButtons.OK, MessageBoxIcon.Warning)
					
					skipFinalErrorMessage = True
					
					End Try
					
				ElseIf window.GetWindowType = ClientWindowType.DocumentViewer Then
					
'The Client Window is not of the "main" type.
'Do nothing and move on.
					
				End If
				
			End If
			
		Next
		
'If no valid windows were processed, inform the user.
		If skipFinalErrorMessage = False Then
			
			MessageBox.Show("The Laserfiche Client must be open, logged in, and in a valid state.", "Laserfiche Form Launcher", MessageBoxButtons.OK, MessageBoxIcon.Warning)
			
		End If
		
	End If
	
'Dispose of the Laserfiche Client instance, to avoid leaked instances of LF.exe.
	client.Dispose()
	
Next

Note: I ended up not using the template name to determine where the master order folder was. I found it less expensive (and easier) to regex the path instead.

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

Sign in to reply to this post.