Commandsite & Search Conditions (Where to place in Handler?)

Commandsite & Search Conditions (Where to place in Handler?)

Tiffany_Hayden_
Collaborator Collaborator
573 Views
1 Reply
Message 1 of 2

Commandsite & Search Conditions (Where to place in Handler?)

Tiffany_Hayden_
Collaborator
Collaborator

Hi 

 

I followed the HelloWorldVB example to create a custom extension within Vault explorer. My question is, is it possible in the handler for there to be a filter or to apply search conditions to where items in the detail pane are filtered out based on the handler or commandsite? I have done many search conditions before. I'm just not sure where you put the search condition inside the handler or the commandsite. The only difference between the handler below and the one in the SDK is I changed it to work on a folder instead. But I'd like to add a filter. If you have any experience with this I'd appreciate some direction. 

 

Thank you!

Tiffany

 

 

        Private Sub Vault_WhereUsedHandler(s As Object, e As CommandItemEventArgs) As ACW.Folder
            Try
                ' The Context part of the event args tells us information about what is selected.
                ' Run some checks to make sure that the selection is valid.
                If e.Context.CurrentSelectionSet.Count() = 0 Then
                    MessageBox.Show("Nothing is selected")
                ElseIf e.Context.CurrentSelectionSet.Count() > 1 Then
                    MessageBox.Show("This function does not support multiple selections")
                Else
                    ' we only have one item selected, which is the expected behavior

                    Dim selection As ISelection = e.Context.CurrentSelectionSet.First()
                    Dim mgr As WebServiceManager = e.Context.Application.Connection.WebServiceManager

                    ' Look of the File object.  How we do this depends on what is selected.
                    Dim selectedFile As ACW.File = Nothing
                    Dim selectedFolder As ACW.Folder = Nothing
                    'If selection.TypeId = SelectionTypeId.File Then
                    '    ' our ISelection.Id is really a File.MasterId
                    '    selectedFile = mgr.DocumentService.GetLatestFileByMasterId(selection.Id)
                    'ElseIf selection.TypeId = SelectionTypeId.FileVersion Then
                    '    ' our ISelection.Id is really a File.Id
                    '    selectedFile = mgr.DocumentService.GetFileById(selection.Id)
                    'End If

                    If selection.TypeId = SelectionTypeId.Folder Then
                        ' our ISelection.Id is really a File.MasterId
                        selectedFolder = mgr.DocumentService.GetFolderById(selection.Id)
                    ElseIf selection.TypeId = SelectionTypeId.FileVersion Then
                        ' our ISelection.Id is really a File.Id
                        selectedFolder = mgr.DocumentService.GetFolderById(selection.Id)
                    End If

                    'If selectedFile Is Nothing Then
                    '    MessageBox.Show("Selection is not a file.")
                    'Else
                    '    ' this is the message we hope to see
                    '    MessageBox.Show([String].Format("Hello World! The file size is: {0} bytes", selectedFile.FileSize))
                    'End If


                    If selectedFolder Is Nothing Then
                        MessageBox.Show("Selection is not a Folder.")
                    Else
                        ' this is the message we hope to see
                        MessageBox.Show([String].Format("Hello World! The file size is: {0} bytes", selectedFolder.FullName))
                    End If



                End If
            Catch ex As Exception
                ' If something goes wrong, we don't want the exception to bubble up to Vault Explorer.
                MessageBox.Show("Error: " & ex.Message)

            End Try




        End Sub

 Commandsites

 

        Public Function CommandSites() As IEnumerable(Of CommandSite) Implements IExplorerExtension.CommandSites
            ' Create the Hello World command object.
            ' this command is active when a File is selected

            ' this command is not active if there are multiple entities selected
            Dim AVMCmdItem As New CommandItem("AdvancedVaultMenu", "Filter Where Used") With {
             .NavigationTypes = New SelectionTypeId() {SelectionTypeId.Folder, SelectionTypeId.FileVersion},
             .MultiSelectEnabled = False
            }

            ' The HelloWorldCommandHandler function is called when the custom command is executed.
            AddHandler AVMCmdItem.Execute, AddressOf Vault_WhereUsedHandler

            ' Create a command site to hook the command to the Advanced toolbar
            Dim toolbarCmdSite As New CommandSite("AdvancedVaultMenu.Toolbar", "Advanced Vault Menu") With {
             .Location = CommandSiteLocation.AdvancedToolbar,
             .DeployAsPulldownMenu = True
            }
            toolbarCmdSite.AddCommand(AVMCmdItem)

            ' Create another command site to hook the command to the right-click menu for Files.
            Dim FolderContextCmdSite As New CommandSite("AdvancedVaultMenu.FolderContextMenu", "Advanced Vault Menu") With {
             .Location = CommandSiteLocation.FolderContextMenu,
             .DeployAsPulldownMenu = True
            }
            FolderContextCmdSite.AddCommand(AVMCmdItem)

            ' Now the custom command is available in 2 places.

            ' Gather the sites in a List.
            Dim sites As New List(Of CommandSite)()
            sites.Add(toolbarCmdSite)
            sites.Add(FolderContextCmdSite)

            ' Return the list of CommandSites.
            Return sites
        End Function

 

 

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
574 Views
1 Reply
Reply (1)
Message 2 of 2

Nick_Hall
Collaborator
Collaborator

Hi Tiffany

 

I'm pretty sure (but not 100%) that you can't apply a filter to the standard Where Used tab

 

If I'm right about this, you will need to create a custom tab, similar to the one in the HelloWorldVB sample, with the functionality you need

 

Not a great help I'm afraid

 

Nick

0 Likes