Example–Load Different Data Standard Dialogs

The XAML files for the File, Folder, and Custom Object entities are pre-configured. However, more XAML files can be created in this directory and different XAML files can be shown for the same entity.

To show different dialogs for the same entity, create a PowerShell file with the content in this directory: %programdata%\Autodesk\Vault [edition]\Extensions\DataStandard\Vault\addinVault\Menus.

Example of a Custom XAML File

$vaultContext.ForceRefresh = $true
$currentSelected = $vaultContext.CurrentSelectionSet[0]
$folderid = $currentSelected.Id
#if selected object is of type 'FILE' then use $vaultContext.NavSelectionSet[0].Id,
#it will give you back the folder Id where this file is located
if ($currentselected.typeid.entityclassid--eq-"file")
{
    $folderid = $vaultContext.NavSelectionSet[0].Id
}

$xamlFile = New-Object CreateObject.WPF.XamlFile "MyOwnXaml", "C:\ProgramData\Autodesk\Vault [edition]\Extensions\DataStandard\Vault\Configuration\myfile.xaml"
$dialog = $dsCommands.GetCreateDialog($folderid)
$dialog.XamlFile = $xamlFile

#new file can be found in $dialog.CurrentFile
$result = $dialog.Execute()
$dsDiag.Trace($result)

if ($result)
{
    $folder = $vault.DocumentService.GetFolderById($folderid)
    $path=$folder.FullName+"/"+$dialog.CurrentFile.Name

    $selectionId = [Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId]::File
    $location = New-Object Autodesk.Connectivity.Explorer.Extensibility.LocationContext $selectionId, $path

    #$dsDiag.Inspect()
    $vaultContext.GoToLocation = $location
}

Once the dialog loads (by $dialog.Execute()) it can be managed using Data Standard Functions. For more information on how to execute the code in the sample above, see Menu Items.