Data Standard - Updating Properties on Multiple Files

Data Standard - Updating Properties on Multiple Files

BruceMcKee
Contributor Contributor
1,902 Views
6 Replies
Message 1 of 7

Data Standard - Updating Properties on Multiple Files

BruceMcKee
Contributor
Contributor

I am working on some custom routines for a client and trying to use the data standard.

 

They are currently on a different document management system and preparing to switch and want the same functionality they previously had.

 

Part of this is being able to update specific properties on selection of documents at the same time.

 

I have used the Data standard created Custom Command / Custom PS1 / Custom XAML I have been able to work through everything except actually applying the updates to the additional files.

 

Here is my code I am currently using

 

 

$vaultContext.ForceRefresh = $true

 

$dialog = $dsCommands.GetEditDialog($fileId)

 

$xamlFile = New-Object CreateObject.WPF.XamlFile "UpdateProjectInfoxaml", "UpdateProjectInfo.xaml"

 

$dialog.XamlFile = $xamlFile

 

$result = $dialog.Execute()

 

if ($result)

 

{

 

  $ids = @()

 

  $propDefIds = @()

 

  $propVals = @()

 

  foreach ($prop in $dialog.ViewModel.Properties)

 

  {

 

    switch($prop.Name)

 

    {

 

      { ($_ -eq "ProjectStatus") } # syntax for adding multiple conditions -or ($_ -eq "ProjectSupervisor") }

 

      {

 

        $propDefIds += $prop.Id;

 

        $propVals += $prop.Value;

 

      }

 

    }

 

  }

 

 

  # just realized add check to not include current file Id in list of Id's

  foreach ($file in $vaultContext.CurrentSelectionSet)

 

  {

    $ids += $file.Id

 

  }

 

 

  $dsDiag.Inspect()

 

 

 

  # Update Files

 

  # $vault.documentservice.UpdateFileProperties($Ids, $propDefIds, $propVals, "Property Update");

 

}

 

The last actual line is where I am having difficulties calling the UpdateFileProperties

 

I will probably need to do the following CheckOutFiles / UpdateFilesProperties / CheckInFiles or is there a better method for this through your data standard.

 

Any sample would be appreciated.

 

Thanks

 

0 Likes
Accepted solutions (1)
1,903 Views
6 Replies
Replies (6)
Message 2 of 7

Patrick.Gruber
Enthusiast
Enthusiast

Hi BruceMcKee,

 

as far as I know, datastandard does not offer you a better solution. It exposes you some important objects in the runspace, which you can work with.

Which vault version do you use? 2015? 2015 R2?

 

Via the documentservice you have to do a checkin / checkout, thats right. But if you would use the explorerutil, then you don't have to do that.

Maybe this article helps you: http://blog.coolorange.com/2013/01/25/updatefileproperties-from-vault-api-in-powershell/ 

 

Best Regards,

Patrick

 

Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos!
😉
The author,
Patrick

coolOrange
www.coolOrange.com
0 Likes
Message 3 of 7

marco.mirandola
Advocate
Advocate
Accepted solution
Hi, as Patrick mentioned, if you like to update multiple files via Data Standard, then you have to do it via the API, as for now. Obiously the one file you edit via Data Standard will be updated by Data Standard, however, the other files you like to update has to be treated separately, as you already recognized.

just instead of using the $vault.documentservice.UpdateFileProperties($Ids, $propDefIds, $propVals, "Property Update"); i would rather then use $vaultExplorerUtil.UpdateFileProperties($file, $dict)

the difference is that the UpdateFileProperties from the $vault ()regular server API) only work with properties that are not mapped and you have to do the check-out/-in. The UpdateFileProperties from the $vaultExplorerUtil (client side API) does all the things for you. So it checks the file out and in and manages the mapped properties.
As a down side, you can perform it just file by file.

here a sample:

$dict = New-Object "System.Collections.Generic.Dictionary[[Autodesk.Connectivity.WebServices.PropDef],[Object]]"
$dict.Add($propDef, "yourValue")
$vaultExplorerUtil.UpdateFileProperties($file, $dict)

The $file id obviously the file you like to update and the $dict is the list of properties with according value. Pay attention as in this case you have to pass the complete property definition, not only the id.

good luck!

ciao
marco

coolOrange
www.coolorange.com
0 Likes
Message 4 of 7

Anonymous
Not applicable

I did something similar recently and it works great for a handful of files. However, I find $vaultExplorerUtil.UpdateFileProperties() to be painfully slow if you update dozends or even hundreds of files. Using coolOrange PowerVault to do the updating seems (didn't Benchmark it) a little faster while native Vault Explorer property editing via UI is much faster.

The Vault Explorer UI being unresponsive for minutes without any indication what is going on is rather unfortunate.

 

Does anybody of you do mass editing like this, too? How do you manage progress reporting?

 

I tried to background the logic doing the property editing via Start-Job because I hoped Vault Explorer would remain usable throughout the Operation this way, but then the script seems to do nothing at all.

 

Any thoughts on this?

0 Likes
Message 5 of 7

Anonymous
Not applicable

@Anonymous wrote:

I find $vaultExplorerUtil.UpdateFileProperties() to be painfully slow if you update dozends or even hundreds of files. [...] while native Vault Explorer property editing via UI is much faster.

 

 


That was my bad, I fear. Further testing showed API call and UI usage to be more or less equal in speed.

 


@Anonymous wrote:

How do you manage progress reporting?

 

I tried to background the logic doing the property editing via Start-Job because I hoped Vault Explorer would remain usable throughout the Operation this way, but then the script seems to do nothing at all.

 


I use Powershell runspaces now and it works fine!

0 Likes
Message 6 of 7

BruceMcKee
Contributor
Contributor
To be honest I would have to agree with you on speed issues unfortunately at this point the util.UpdateFileProperties is the method that we are using in our development just due to the complexity of updating properties using the API.

I would hope someone would be able to provide some sort of sample that would show how to updates hundreds if not thousands of files when all files need to have the same values applied for a specific set of Properties.

Fortunately the programming I am working on right now is more specific than that each file requires unique values to be applied and the UpdateFileProperties appear to be the best approach.

If you happen to find a solution I would be grateful if you would share.

Thanks
Bruce
0 Likes
Message 7 of 7

Anonymous
Not applicable

What I wanted to say was: Yes, it is quite slow, but it is not significantly slower than using the native UI. So i figured I couldn't ask for more.

 

As it turns out, I was wrong again. I did a new testrun just now: I updated one property with a new value on 780 files between 0 byte and 117 Mbyte.

 

My first impression was quite right - the UI method is much faster than my Powershell script, about 5.5 times faster. 

 

 

0 Likes