Vault Data Standard 2019-Template File - Mass Property pull to dialog box

Vault Data Standard 2019-Template File - Mass Property pull to dialog box

Anonymous
Not applicable
1,327 Views
2 Replies
Message 1 of 3

Vault Data Standard 2019-Template File - Mass Property pull to dialog box

Anonymous
Not applicable

 

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

 

 

file_display_issue.png
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

}
}
}

 

0 Likes
Accepted solutions (1)
1,328 Views
2 Replies
Replies (2)
Message 2 of 3

wangdu
Collaborator
Collaborator

Hi,

How about this? (Note the code isn't tested!)

function FillFileProperties($fileId)
{
  $global:propDefs = 
  $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
  $props = $vault.PropertyService.GetPropertiesByEntityIds("FILE",@($fileId))
  foreach ($property in $props) {
    $propDef = $global:propDefs | Where-Object { $_.Id -eq $property.PropDefId }
    $prop[$propDef.DispName] = $property.Val
  }
}

I have just changed the function: GetFileProperties -> FillFileProperties. Instead of returning it back and then filling the $prop, now the $prop is filled directly inside the function itself. It helps you now not to have to update it everytime you wish to add something.

About the sorting, if you are using DynamicProperties grid from the VDS, then sorting can be accomplished by manually changing the list that you find in the file 'VaultDynamicProperties.xml' file within the Configuration folder.

 

Hope it helps!

Wangdu

 

coolOrange

www.coolOrange.com

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

I did finally figure out how to deal with this. 

 

 

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

foreach ($key in $properties.keys) {
$Prop[$key].Value = $properties[$key]
}

}

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

}
}
}

 

0 Likes