Add-VaultMenuItem
Creates a new menu item in a Vault Client menu with an Action that is invoked when the menu item is clicked.
Syntax
Add-VaultMenuItem -Location <VaultExplorerMenu> -Name <String> [-Submenu <string>] -Action <Scriptblock | String> [<CommonParameters>]
Parameters
Type |
Name |
Description |
Default Value |
Optional |
---|---|---|---|---|
Location |
The menu in Vault Client where the item will be added (e.g. Tools or right-click menu) |
no |
||
String |
Name |
Display name of the new menu item. You can use HTML tags to format the display text. |
no |
|
String |
Submenu |
Adds the menu item to a submenu. You can use HTML tags to format the display text. |
|
yes |
Scriptblock / String |
Action |
Script block or function with one parameter ( |
no |
VaultExplorerMenu
Enum values:
Name |
Description |
---|---|
ToolsMenu |
Tools menu in Vault’s Main Menu toolbar |
FileContextMenu |
Right-click menu for Files |
ItemContextMenu |
Right-click menu for Items |
ChangeOrderContextMenu |
Right-click menu for Change Orders |
FolderContextMenu |
Right-click menu for Folders |
Return type
empty
Remarks
The cmdlet adds a new menu item to the user interface of the Vault Client with the specified -Name, and optionally also in a given -Submenu.
When the menu item is clicked, the script block or function passed as parameter -Action is invoked. All entities selected in the Vault Client are passed as an array of powerVault entities.
Tools menu
New menu items appear directly in the Vault Client’s Tools menu by default. Optionally, the name of a -Submenu can be specified under which the item should be displayed.
Only entities that are selected in the main Vault Explorer window are passed to the -Action parameter. These can therefore be, for example, powerVault Files, Folders, Items or Change Orders.
Selections from other windows, such as the Search dialog or Edit Item window, are ignored.
Context menus
By default, new menu items are grouped under a submenu called “COOLORANGE”. When passing an empty -Submenu string, the item will be directly displayed in the right-click menu and does not appear in a submenu.
Depending on the -Location setting, the the objects passed to the -Action can be:
FileContextMenu
: Only powerVault File objecctsFolderContextMenu
: Only Folder objectsItemContextMenu
: Only Item objectsChangeOrderContextMenu
: Only Change Order objects
Menu items cannot be removed or renamed once they once they have been added. If the cmdlet is called again with the same -Location and -Name, it will update the -Action.
Warning: Name must be unique
Therefore, when multiple menu items for the same Location are registered, the -Name parameter must be unique for each menu item.
Note
The cmdlet can only be used when running directly in a Vault Explorer Process
Created menu items 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 menu item is displayed in every Vault Client session.
Examples
The following samples are meant to be saved as .ps1 files in the Client Customizations folder.
Create a new menu item under Tools->COOLORANGE, to open the log directory in Windows Explorer:
Add-VaultMenuItem -Location ToolsMenu `
-Name 'Open Log directory' `
-Submenu "<font='Montserrat'>COOL<b><color=#F7941D>ORANGE</color></b></font>" ` #for more HTML styling capabilities see https://docs.devexpress.com/WindowsForms/4874/common-features/html-text-formatting
-Action {
explorer.exe "$env:LOCALAPPDATA\coolOrange\powerEvents\Logs"
}
Create a right-click menu item to queue a DWF job if the selected File type is supported:
Add-VaultMenuItem -Location FileContextMenu -Name 'Queue DWF job' -Submenu '' -Action 'SubmitDWFJob'
function SubmitDWFJob($entities) {
foreach($file in $entities) {
if($file._Extension -in @('iam', 'ipt', 'ipn', 'idw', 'dwg', 'dxf', 'rvt', 'rfa', 'rte', 'nwd', 'nwf', 'nwc', 'ifc')) {
Add-VaultJob -Name "Autodesk.Vault.DWF.Create.$($file._Extension)" -Parameters @{'FileVersionId' = $file.Id} -Priority 10
} else {
[System.Windows.Forms.MessageBox]::Show("File extension '$($file._Extension)' is not supported!")
}
}
}
Adds a Folder context menu item in the ‘COOLORANGE’ submenu to queue PDF jobs for all files in the selected folders:
Add-VaultMenuItem -Location FolderContextMenu -Name "Create PDF's for all files in folder" -Action {
param($entities)
foreach($folder in $entities){
$files = Get-VaultFiles -Folder $folder._FullPath
foreach($file in $files) {
Add-VaultJob -Name 'Sample.CreatePDF' -Parameters @{'EntityId'=$file.Id; 'EntityClassId'='File'} -Description "Create PDF for: $($file._Name)" -Priority 10
}
}
}
Adds a right-click menu item to manually submit the powerPLM (powerFLC) ‘Sample.TransferItemBOMs’ job on selected Vault Items:
Add-VaultMenuItem -Location ItemContextMenu -Name 'Transfer Item BOM to FLC' -Action {
param($entities)
foreach($item in $entities){
Add-VaultJob -Name 'Sample.TransferItemBOMs' -Parameters @{'EntityId'=$item.Id; 'EntityClassId'='Item'} -Description "Transfer Item BOMs for: $($item._Number)"
}
}