# Add-VaultTab Adding a new Tab for a specific entity type to the Vault Explorer with an Action that is called when the Tab is clicked or the selection changes in Vault.\ The cmdlet provides the possibility to define a user interface for the registered Tab. ## Syntax ```powershell Add-VaultTab -Name -EntityType -Action [] ``` ## Parameters | Type | Name | Description | Default Value | Optional | |-------------------------------------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------| | String | Name | Label of the Tab displayed in the Vault Explorer. | | no | | VaultTabEntityType | EntityType | The entity type for which the Tab should be displayed.
Possible values are: *File*, *Folder*, *Item* and *Custom Object Definition Name (e.g. [Task, Contact]()).* | | no | | | no | | Scriptblock / String | Action | Script block or function that gets executed for the currently selected entity in the Vault Client (`$selectedEntity`) if the Tab is activated.
This can be used to define or update the Tab interface by simply returning a [WPF Control]() from the script block or function. | | no | ## Return type **empty** ## Remarks The Cmdlet extends the Vault Client's user interface with a new tab with the specified **-Name** as its label.\ When multiple tabs with the same *-Name* for the same *-EntityType* are registered, only the latest registered tab is displayed. The script block or the function name passed as **-Action** parameter is invoked for the element that is selected in the Vault Client.\ This can be a [powerVault File](), a [](), an []() or a [](), depending on the specified **-EntityType**.\ The *Action* runs whenever the user activates the tab, or selects a different element while the tab is visible.\ If multiple elements are selected, the first selected entity will be used. In case the _Action_ returns an invalid [WPF Control](https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.control?view=netframework-4.5) or if an unhandled terminating exception occurs in the Vault Client's UI thread, the tab content is **cleared** and details are logged. :::{note} - The cmdlet can **only be used** when running directly in a **Vault Explorer** process. - Created tabs remain available as long as this process exists and disappear again when the Vault Client is restarted. - Only the use of the cmdlet in client customization [scripts]() ensures that the tab is displayed in every Vault Client session. - The Vault Client remembers activated Tabs (based on their position) even after a restart. In this case, the passed *-Action* gets invoked immediately after [LoginVault]() event registrations. ::: ## Examples **Adds a tab for Files displaying a DataGrid with their FileBom rows:** ```{image} /img/Add_VaultTab_SampleFileBOM.png :align: right :width: 40% ``` ```powershell Add-VaultTab -EntityType File -Name 'Sample File BOM' -Action { param($selectedFile) $fileBom = Get-VaultFileBOM -File $selectedFile._FullPath if(-not $fileBom) { return BuildFromXaml @' '@ } #Print BOM data as Table like in Inventor $bomrows_table = BuildFromXaml @' '@ $bomrows_table.ItemsSource = @($fileBom | sort-object {[int]$_.Bom_PositionNumber}) return $bomrows_table } function BuildFromXaml([xml]$xaml){ $xamlReader = New-Object System.Xml.XmlNodeReader $xaml return [Windows.Markup.XamlReader]::Load($xamlReader) } ``` **Adds a tab for Items that displays their Thumbnail image:** ```powershell Add-VaultTab -EntityType Item -Name 'Thumbnail' -Action 'DisplayItemThumbnail' function DisplayItemThumbnail($selectedItem){ $imageControl = New-Object System.Windows.Controls.Image $imageControl.Source = $selectedItem._Thumbnail.Image return $imageControl } ``` **Adds a tab for Folders to display information from Fusion Lifecycle using [powerPLM (powerFLC)]():** ```powershell #Connect-FLC Add-VaultTab -EntityType Folder -Name 'Fusion Lifecycle' -Action { param($selectedFolder) $flcItem = Get-FLCItems -Workspace 'Products' -Filter "ITEM_DETAILS:NUMBER=$($selectedFolder._Name)" -ErrorAction Continue $tab_control = [Windows.Markup.XamlReader]::Load([Xml.XmlNodeReader]::new([xml] @" $( if($global:flcConnection) { "" } else { "" } ) $( if($flcItem) { '' } else { '' } ) $($flcItem.Number) $($flcItem.Description)