Customize Menu to Add New Custom Object

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am using Data Standards with PowerVault trying to modify the default RMB Context menu entry to create "New Custom Object..." and I wanted kindly request for some assistance, as my programming skills are not that good to be honest.
I have created a Custom Object Definition in the Vault client called "Companies" and created three companies inside by using the default context-menu command that appears when you RMB (Right-Mouse-Button) the "Companies" Object definition.
I would like to modify the dialog box that this command fires up, or even better, to create my own RMB context menu command and my own XAML form that I am creating in Visual Studio.
In the "mymenu.mnu" file, I have created a new 'item' and 'site' as per below:
item newCompanyObj
{
Description = "$UIString[MNU24]";
Id = "myNewCompanyObject";
Hint = "$UIString[MNU25]";
Label = "$UIString[MNU26]";
MultiSelectEnabled = false;
NavigationTypes = [{$UIString[MNU30]}];
ToolbarPaintStyle = TextAndGlyph;
PSFile = "NewCompanyObject.ps1";
Image="icon-building.ico";
}
site Company
{
Id="DSCompany";
Label="Company";
DeployAsPulldown=false;
Location={Company,ContextMenu};
MenuItems=[$newCompanyObj];
}
My first question in the above file is: How do I get my command to appear when I actually RMB on the Custom Object Definition ("Companies") and not when I RMB on one of the companies instance I have already create, which is what is happening with the code above?
I have tried to research this and from what I understand, I might have to create my SelectionTypeId... I think I have the right code to do that below, but I have no idea where to place this code to get to work.
$selectionType = New-Object -TypeName Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId {Company}
Anyway, at the moment I can see my command (in the wrong place) and it fires up my XAML form, but I am then struggling to get it to actually create my Custom Object entry (New Company) - Please see code below for "NewCompanyObject.ps1"
Import-Module powerVault
$companyId = $vaultContext.CurrentSelectionSet[0].Id
$dialog = $dsCommands.GetCreateCustomObjectDialog($companyId)
$xamlFile = New-Object CreateObject.WPF.XamlFile "CustomEntityXaml", "%ProgramData%\Autodesk\Vault 2016\Extensions\DataStandard\Vault\Configuration\Company\Company.xaml"
$dialog.XamlFile = $xamlFile
$SelectionType = New-Object -TypeName Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId(SelectionTypeId.Company)
$result = $dialog.Execute()
$dsDiag.Trace($result)
if($result)
{
$customObjects = $vault.CustomEntityService.GetAllCustomEntityDefinitions() | Where-Object { $_.dispName -eq "Company" }
$SelectionType = New-Object -TypeName Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId {Company}
$companyName = "TEST COMPANY"
$newCompany = New-Object -TypeName $vault.CustomEntityService.AddCustomEntity ($customObjects.Id, $companyName)
}
The error I am getting is:
New-Object : Cannot find type [Autodesk.Connectivity.WebServices.CustEnt AddCustomEntity(long custEntDefId, string name)]: make sure the assembly containing this type is loaded.
I am probably using the wrong assembly but I have no way to find out what is needed... I noticed in some of Marco Mirandole's videos of PowerVault, there is an extra toolbar on the right with Command Lets but I have no idea how to activate this.. I have installed PowerGate, PowerJobs but this is still not available. I am generally struggling to find an effective way to be able to dig into the different functions available and their syntax.
A prompt response and assistance would be greatly appreciated.
Best Regards,
Vas