By Barbara Han
Issue
While trying to write an app that allows me to update multiple file properties to a preset series of values, I was looking to use the Edit properties function of Vault Explorer. Can it be achieved through the Vault API?
Solution
If you have access to Vault Workgroup or Vault Collaboration or Vault Professional, it is possible to edit the file properties through the API ‘UpdateFileProperties’ from DocumentServiceExtensions service (not available in base version of Vault).
The UpdateFileProperties method can update the user defined property values, for example:
PropInst[] myInst = docSvcExt.UpdateFileProperties(fileMasterIds, propDefIds, propValues, "Property Update");
If what you care about is a user defined property, then you are done at this point. However, if the property is mapped to a derived property, then things get more complex.
Here there are two definitions related:
- User Defined Property: A property that lives in the Vault and can be edited by a client. Also known as Custom Property.
- Derived Property: A property that lives in the file. Editing can only be done by checking out the file, editing the file, and checking it back in.
For mapped property, you might need "write back" the user defined property to the file, and this can be done using ExplorerUtil.UpdateFileProperties method. For more details of this method, please read this post and Vault API help document. You can also do the ‘write back’ by yourself - check out the file via Vault API, and then use CAD product’s API to edit the file properties. For example, for Inventor file, you can use Inventor Apprentice API to edit the iProperties of the file. For more details of Inventor Apprentice please look at this page.
You may also need run the "property sync" command from the UI or creating a property sync job. The ability to create a job is only available in Vault Collaboration or Vault Professional.
If you want to do a “property sync” via API, you can refer to this post: Add property synchronization job