- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
On new file creation I am bring in the File Template Properties into the dialog box. However; I'm Doing this one by one by calling out the variable.
ie... $Prop["Title"].Value = $properties["Title"]
What I would prefer to do is to bring in all the properties attached to the category at once that way it's dynamic as I start adding new categories to the vault.
The secondary issue I am having is being able to set the order in which those properties appear in the display area. Since I would like things like Project that are more global variables to show up at the top of the list. Would prefer if this was
1. Bring All User Defined Properties from the Template with the ability to over-ride them.
2. Change display order of User Defined properties. -- Probably per Category
function OnTemplateChanged
{
$context = $dsWindow.DataContext
$path = $context.TemplatePath
$file = $context.SelectedTemplate
$template = $path + "/" + $file
$folder = $vault.DocumentService.GetFolderByPath($path)
$files = $vault.DocumentService.GetLatestFilesByFolderId($folder.Id,$false)
$file = $files | Where-Object { $_.Name -eq $file }
$Prop["_Category"].Value = $file.Cat.CatName
$properties = GetFileProperties -fileId $file.Id
$Prop["Title"].Value = $properties["Title"]
$Prop["Subject"].Value = $properties["Subject"]
$Prop["Project"].Value = $properties["Project"]
$Prop["Author"].Value = $properties["Author"]
$Prop["Engineer"].Value = $properties["Engineer"]
$Prop["Company"].Value = $properties["Company"]
$Prop["Description"].Value = $properties["Description"]
$Prop["DWG Type"].Value = $properties["DWG Type"]
$Prop["Material"].Value = $properties["Material"]
$Prop["Keywords"].Value = $properties["Keywords"]
$Prop["Comments"].Value = $properties["Comments"]
$Prop["Stock Number"].Value = $properties["Stock Number"]
$Prop["Part Number"].Value = $properties["Part Number"]
}
-------------------------------------------------------------------------------------------
function GetFileProperties($fileId)
{
$global:propDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
$props = $vault.PropertyService.GetPropertiesByEntityIds("FILE",@($fileId))
$properties = @{}
foreach ($prop in $props) {
$propDef = $global:propDefs | Where-Object { $_.Id -eq $prop.PropDefId }
$properties[$propDef.DispName] = $Prop.Val
}
return $properties
}
------------------------------
function InitializeWindow
{
#begin rules applying commonly
InitializeWindowTitle
InitializeNumSchm
InitializeCategory
#end rules applying commonly
$mWindowName = $dsWindow.Name
switch($mWindowName)
{
"FileWindow"
{
#rules applying for File
$dsWindow.FindName("TemplateCB").add_SelectionChanged({
OnTemplateChanged})
}
"FolderWindow"
{
#rules applying for Folder
}
"CustomObjectWindow"
{
#rules applying for Custom Object
}
}
}
Solved! Go to Solution.