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> -Icon <VaultMenuIcon> [<CommonParameters>]

Parameters

Type

Name

Description

Default Value

Optional

VaultExplorerMenu

Location

The menu in Vault Client where and for which EntityType 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.
If an empty string is provided, the item is displayed directly in the menu and does not appear in a submenu.

"" for Tools menu,
"COOLORANGE" for right-click menus

yes

Scriptblock / String

Action

Script block or function with one parameter ($entities) that is executed when the menu item is clicked.

no

VaultMenuIcon

Icon

Image that will appear on the left of the display name of the menu item.

yes

VaultExplorerMenu

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

{Custom Object Definition Name}ContextMenu

Right-click menu for the specified Custom Objects

VaultMenuIcon

AddComment AddComment

AddFile AddFile

AddFiles AddFiles

Approve Approve

ArrowDown ArrowDown

ArrowUp ArrowUp

AssignCategory AssignCategory

AttachmentPrimary AttachmentPrimary

AttachmentSecondary AttachmentSecondary

Attachments Attachments

Back Back

BomRemove BomRemove

BulbOFF BulbOFF

BulbON BulbON

Bulbs Bulbs

Calendar Calendar

Categories Categories

ChangeOrder ChangeOrder

ChangeOrderList ChangeOrderList

ChangeRevision ChangeRevision

ChangeState ChangeState

Check Check

ClearFilter ClearFilter

Collapse Collapse

ComponentEdit ComponentEdit

Copy Copy

CopyDesign CopyDesign

CopyDesignCopy CopyDesignCopy

CopyDesignEdit CopyDesignEdit

CopyDesignReplace CopyDesignReplace

CopyFolder CopyFolder

Create Create

CreateDXF CreateDXF

CreatePDF CreatePDF

CreateSTP CreateSTP

Cross Cross

CustomFilter CustomFilter

CustomObjects CustomObjects

CustomizeViewGroup CustomizeViewGroup

Dashboard Dashboard

Document Document

DoubleArrow DoubleArrow

Download Download

Edit Edit

ERPExport ERPExport

ERPImport ERPImport

Expand Expand

Export Export

FindAndReplace FindAndReplace

First First

FolderClosed FolderClosed

FolderClosedLocked FolderClosedLocked

FolderOpen FolderOpen

FolderOpenLocked FolderOpenLocked

FolderView FolderView

FutureFolder FutureFolder

GreenRowArrow GreenRowArrow

Groups Groups

HasModelState HasModelState

Help Help

IncludeDependents IncludeDependents

Information Information

Item Item

ItemMaster ItemMaster

Last Last

Layout Layout

Library Library

LibraryLocked LibraryLocked

Lifecycle Lifecycle

Link Link

List List

Locked Locked

Log Log

LoggedIn LoggedIn

LoggedOut LoggedOut

MoveToFolder MoveToFolder

New New

NewFolder NewFolder

NoModelState NoModelState

NonReleased NonReleased

NumberingScheme NumberingScheme

PackAndGo PackAndGo

Paste Paste

Pause Pause

Pin Pin

Plot Plot

PlotComplete PlotComplete

Preview Preview

PreviewWindow PreviewWindow

Promote Promote

Property Property

PropertyNonCompliant PropertyNonCompliant

PropertyType PropertyType

RedRowArrow RedRowArrow

Refresh Refresh

Released Released

Remove Remove

Renumber Renumber

Report Report

Resume Resume

ReviewStatus ReviewStatus

RevisionBlockRevert RevisionBlockRevert

Save Save

Search Search

Server Server

Servers Servers

Shortcut Shortcut

Sites Sites

SortAscending SortAscending

SortDescending SortDescending

SubstitutePart SubstitutePart

Thumbnail Thumbnail

Tick Tick

UncommittedTip UncommittedTip

Unpin Unpin

UpdateItem UpdateItem

Uplevel Uplevel

UsesView UsesView

ViewOptions ViewOptions

Warning Warning

coolOrange coolOrange

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, Change Orders or Custom Objects.
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.

In order to add new menu items for specific Custom Objects, the following naming convention must be followed:
The Name of the Custom Object Definition, followed by the suffix “ContextMenu”. For example, if you have a custom object definition Task, the value TaskContextMenu would have to be used for the -Location argument.

Depending on the -Location setting, the the objects passed to the -Action can be:

  • FileContextMenu: Only powerVault File objects

  • FolderContextMenu: Only Folder objects

  • ItemContextMenu: Only Item objects

  • ChangeOrderContextMenu: Only Change Order objects

  • {Custom Object Definition Name}ContextMenu: Only specified Custom Object objects

Menu items cannot be removed or renamed 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 with a coolOrange icon, 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
    -Icon coolOrange
    -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 a powerPLM workflow job for selected Vault Items:

Add-VaultMenuItem -Location ItemContextMenu -Name 'Transfer Item BOMs to PLM' -Action {
    param($selectedItems)

    foreach($item in $selectedItems) {
        Add-VaultJob -Name 'Sample.TransferItemBOMs' -Parameters @{'EntityId'=$item.Id; 'EntityClassId'='Item'} -Description "Transfer Item BOMs for: $($item._Number)"
        #Note: The according job can be downloaded from https://github.com/coolOrangeSamples/powerflc-samples/tree/master/Sample.TransferItemBOMs
    }
}

Adds a right-click menu item for the Custom Object ‘Change Order Task’ that opens the associated Change Task in Fusion 360 Manage:

#Connect-FLC -Tenant ... -ClientId ... -ClientSecret ...

Add-VaultMenuItem -Location 'Change Order TaskContextMenu' -Name 'Go To Change Task..' -Action {
    param($entities)

    $selectedChangeOrderTask = $entities[0]._Name
    $flcItem = (Get-FLCItems -Workspace 'Change Tasks' -Filter "ITEM_DETAILS:TITLE=`"$selectedChangeOrderTask`"")[0]
    $navigationUrl = "$($flcConnection.Url)plm/workspaces/$($flcConnection.Workspaces.Find($flcItem.Workspace).Id)/items/itemDetails?view=split&itemId=urn%60adsk,plm%60tenant,workspace,item%60$($flcConnection.Tenant.ToUpper()),$($flcConnection.Workspaces.Find($flcItem.Workspace).Id),$($flcItem.Id)"
    Start-Process $navigationUrl
}